mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
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:
parent
a1f7f5d4d0
commit
59fa40ec0e
2 changed files with 14 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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'});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue