Skip to content

Commit

Permalink
fix(ngRoute): remove extra decodeURIComponent
Browse files Browse the repository at this point in the history
Since `$location.$$path` is already decoded, doing an extra `decodeURIComponent` is both unnecessary and can cause problems. Specifically, if the path originally included an encoded `%` (aka `%25`), then ngRoute will throw "URIError: URI malformed".

Closes angular#6326
  • Loading branch information
mllrjb committed Feb 19, 2014
1 parent 1b74e5e commit 25cd925
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/ngRoute/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,7 @@ function $RouteProvider(){
for (var i = 1, len = m.length; i < len; ++i) {
var key = keys[i - 1];

var val = 'string' == typeof m[i]
? decodeURIComponent(m[i])
: m[i];
var val = m[i];

if (key && val) {
params[key.name] = val;
Expand Down
6 changes: 6 additions & 0 deletions test/ngRoute/routeSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,12 @@ describe('$route', function() {
$rootScope.$digest();
expect($route.current).toBeDefined();
}));

it('matches a URL with even more special chars', inject(function($route, $location, $rootScope) {
$location.path('/$test.23/foo*(bar)/~!@#$%^&*()_+=-`');
$rootScope.$digest();
expect($route.current).toBeDefined();
}));
});


Expand Down

0 comments on commit 25cd925

Please sign in to comment.