Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 59fa40e

Browse files
mkotsurIgorMinar
authored andcommitted
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
1 parent a1f7f5d commit 59fa40e

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/ng/location.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ LocationUrl.prototype = {
335335
if (paramValue === null) {
336336
delete this.$$search[search];
337337
} else {
338-
this.$$search[search] = encodeUriQuery(paramValue);
338+
this.$$search[search] = paramValue;
339339
}
340340
} else {
341341
this.$$search = isString(search) ? parseKeyValue(search) : search;

test/ng/locationSpec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,19 @@ describe('$location', function() {
330330
expect(url.search()).toEqual({'i j': '<>#'});
331331
expect(url.hash()).toBe('x <>#');
332332
});
333+
334+
335+
it('should return decoded characters for search specified in URL', function() {
336+
var locationUrl = new LocationUrl('http://host.com/?q=1%2F2%203');
337+
expect(locationUrl.search()).toEqual({'q': '1/2 3'});
338+
});
339+
340+
341+
it('should return decoded characters for search specified with setter', function() {
342+
var locationUrl = new LocationUrl('http://host.com/');
343+
locationUrl.search('q', '1/2 3');
344+
expect(locationUrl.search()).toEqual({'q': '1/2 3'});
345+
});
333346
});
334347
});
335348

0 commit comments

Comments
 (0)