fix($location): search setter should not double-encode the value

By mistake both the setter and helper function that composes the whole
url were encoding the search values.

Closes #751
This commit is contained in:
Mykhailo Kotsur 2012-03-29 22:16:10 +02:00 committed by Igor Minar
parent a1f7f5d4d0
commit 59fa40ec0e
2 changed files with 14 additions and 1 deletions

View file

@ -335,7 +335,7 @@ LocationUrl.prototype = {
if (paramValue === null) {
delete this.$$search[search];
} else {
this.$$search[search] = encodeUriQuery(paramValue);
this.$$search[search] = paramValue;
}
} else {
this.$$search = isString(search) ? parseKeyValue(search) : search;

View file

@ -330,6 +330,19 @@ describe('$location', function() {
expect(url.search()).toEqual({'i j': '<>#'});
expect(url.hash()).toBe('x <>#');
});
it('should return decoded characters for search specified in URL', function() {
var locationUrl = new LocationUrl('http://host.com/?q=1%2F2%203');
expect(locationUrl.search()).toEqual({'q': '1/2 3'});
});
it('should return decoded characters for search specified with setter', function() {
var locationUrl = new LocationUrl('http://host.com/');
locationUrl.search('q', '1/2 3');
expect(locationUrl.search()).toEqual({'q': '1/2 3'});
});
});
});