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

Commit

Permalink
fix($location): decode non-component special chars in Hashbang URLS
Browse files Browse the repository at this point in the history
  • Loading branch information
petebacondarwin committed Nov 30, 2017
1 parent 8b69d91 commit 199d888
Show file tree
Hide file tree
Showing 2 changed files with 15 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 @@ -422,7 +422,7 @@ var locationPrototype = {
}

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

Expand Down
14 changes: 14 additions & 0 deletions test/ng/locationSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,20 @@ describe('$location', function() {
locationUrl.search({'q': '4/5 6'});
expect(locationUrl.absUrl()).toEqual('http://host.com?q=4%2F5%206');
});

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

it('url() should not 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');
});
});
});

Expand Down

0 comments on commit 199d888

Please sign in to comment.