Skip to content

Commit 25cd925

Browse files
committed
fix(ngRoute): remove extra decodeURIComponent
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
1 parent 1b74e5e commit 25cd925

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/ngRoute/route.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,7 @@ function $RouteProvider(){
465465
for (var i = 1, len = m.length; i < len; ++i) {
466466
var key = keys[i - 1];
467467

468-
var val = 'string' == typeof m[i]
469-
? decodeURIComponent(m[i])
470-
: m[i];
468+
var val = m[i];
471469

472470
if (key && val) {
473471
params[key.name] = val;

test/ngRoute/routeSpec.js

+6
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,12 @@ describe('$route', function() {
242242
$rootScope.$digest();
243243
expect($route.current).toBeDefined();
244244
}));
245+
246+
it('matches a URL with even more special chars', inject(function($route, $location, $rootScope) {
247+
$location.path('/$test.23/foo*(bar)/~!@#$%^&*()_+=-`');
248+
$rootScope.$digest();
249+
expect($route.current).toBeDefined();
250+
}));
245251
});
246252

247253

0 commit comments

Comments
 (0)