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

Commit 1b77902

Browse files
mllrjbpetebacondarwin
authored andcommitted
fix(ngRoute): remove unnecessary call to decodeURIComponent
Since `$location.$$path` is already decoded, doing an extra `decodeURIComponent` is both unnecessary and can cause problems. Specifically, if the path originally includes an encoded `%` (aka `%25`), then ngRoute will throw "URIError: URI malformed". Closes #6326 Closes #6327
1 parent 49b2a1c commit 1b77902

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/ngRoute/route.js

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

471-
var val = 'string' == typeof m[i]
472-
? decodeURIComponent(m[i])
473-
: m[i];
471+
var val = m[i];
474472

475473
if (key && val) {
476474
params[key.name] = val;

test/ngRoute/routeSpec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,13 @@ describe('$route', function() {
219219
expect($route.current).toBeUndefined();
220220
}));
221221

222-
it('matches literal .', inject(function($route, $location, $rootScope) {
222+
it('matches literal *', inject(function($route, $location, $rootScope) {
223223
$location.path('/$testX23/foo*(bar)/222');
224224
$rootScope.$digest();
225225
expect($route.current).toBeUndefined();
226226
}));
227227

228-
it('matches literal *', inject(function($route, $location, $rootScope) {
228+
it('matches literal .', inject(function($route, $location, $rootScope) {
229229
$location.path('/$test.23/foooo(bar)/222');
230230
$rootScope.$digest();
231231
expect($route.current).toBeUndefined();
@@ -238,7 +238,7 @@ describe('$route', function() {
238238
}));
239239

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

0 commit comments

Comments
 (0)