mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
Fixed cookies which contained unescaped '=' would not show up in cookie service.
This commit is contained in:
parent
d304b0c3df
commit
26bad2bf87
3 changed files with 12 additions and 10 deletions
|
|
@ -1,7 +1,8 @@
|
|||
<a name="0.9.13"><a/>
|
||||
# <angular/> 0.9.13 curdling-stare (in-progress) #
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
- Fixed cookies which contained unescaped '=' would not show up in cookie service.
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ function Browser(window, document, body, XHR, $log) {
|
|||
* @returns {Object} Hash of all cookies (if called without any parameter)
|
||||
*/
|
||||
self.cookies = function (name, value) {
|
||||
var cookieLength, cookieArray, i, keyValue;
|
||||
var cookieLength, cookieArray, cookie, i, keyValue, index;
|
||||
|
||||
if (name) {
|
||||
if (value === _undefined) {
|
||||
|
|
@ -307,9 +307,10 @@ function Browser(window, document, body, XHR, $log) {
|
|||
lastCookies = {};
|
||||
|
||||
for (i = 0; i < cookieArray.length; i++) {
|
||||
keyValue = cookieArray[i].split("=");
|
||||
if (keyValue.length === 2) { //ignore nameless cookies
|
||||
lastCookies[unescape(keyValue[0])] = unescape(keyValue[1]);
|
||||
cookie = cookieArray[i];
|
||||
index = cookie.indexOf('=');
|
||||
if (index > 0) { //ignore nameless cookies
|
||||
lastCookies[unescape(cookie.substring(0, index))] = unescape(cookie.substring(index + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,9 +168,9 @@ describe('browser', function(){
|
|||
describe('put via cookies(cookieName, string)', function() {
|
||||
|
||||
it('should create and store a cookie', function() {
|
||||
browser.cookies('cookieName', 'cookieValue');
|
||||
expect(document.cookie).toMatch(/cookieName=cookieValue;? ?/);
|
||||
expect(browser.cookies()).toEqual({'cookieName':'cookieValue'});
|
||||
browser.cookies('cookieName', 'cookie=Value');
|
||||
expect(document.cookie).toMatch(/cookieName=cookie%3DValue;? ?/);
|
||||
expect(browser.cookies()).toEqual({'cookieName':'cookie=Value'});
|
||||
});
|
||||
|
||||
|
||||
|
|
@ -263,8 +263,8 @@ describe('browser', function(){
|
|||
|
||||
|
||||
it ('should return a value for an existing cookie', function() {
|
||||
document.cookie = "foo=bar";
|
||||
expect(browser.cookies().foo).toEqual('bar');
|
||||
document.cookie = "foo=bar=baz";
|
||||
expect(browser.cookies().foo).toEqual('bar=baz');
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue