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

Commit

Permalink
fix($location): search setter should not double-encode the value
Browse files Browse the repository at this point in the history
By mistake both the setter and helper function that composes the whole
url were encoding the search values.

Closes #751
  • Loading branch information
mkotsur authored and IgorMinar committed Apr 2, 2012
1 parent a1f7f5d commit 59fa40e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ng/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 13 additions & 0 deletions test/ng/locationSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'});
});
});
});

Expand Down

0 comments on commit 59fa40e

Please sign in to comment.