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

fix($location): always decode special chars in $location.url(value) #16354

Merged
merged 1 commit into from
Dec 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ng/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ var locationPrototype = {
}

var match = PATH_MATCH.exec(url);
if (match[1] || url === '') this.path((this.$$html5 ? decodeURI : decodeURIComponent)(match[1]));
if (match[1] || url === '') this.path(decodeURIComponent(match[1]));
if (match[2] || match[1] || url === '') this.search(match[3] || '');
this.hash(match[5] || '');

Expand Down
4 changes: 2 additions & 2 deletions test/ng/locationSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -681,11 +681,11 @@ describe('$location', function() {
expect(locationUrl.path()).toEqual('/foo:bar');
});

it('url() should not decode non-component special characters in html5 mode', function() {
it('url() should decode non-component special characters in html5 mode', function() {
var locationUrl = new LocationHtml5Url('http://host.com', 'http://host.com');
locationUrl.$$parse('http://host.com');
locationUrl.url('/foo%3Abar');
expect(locationUrl.path()).toEqual('/foo%3Abar');
expect(locationUrl.path()).toEqual('/foo:bar');
});
});
});
Expand Down