From 25cd925d302fbfa630d816fe09645988e9dce3b2 Mon Sep 17 00:00:00 2001 From: Jason Miller Date: Tue, 18 Feb 2014 16:26:00 -0700 Subject: [PATCH] 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 #6326 --- src/ngRoute/route.js | 4 +--- test/ngRoute/routeSpec.js | 6 ++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ngRoute/route.js b/src/ngRoute/route.js index fe5d8ec76750..085170a829d7 100644 --- a/src/ngRoute/route.js +++ b/src/ngRoute/route.js @@ -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; diff --git a/test/ngRoute/routeSpec.js b/test/ngRoute/routeSpec.js index de7ccb8d593d..6e8dcaad81ab 100644 --- a/test/ngRoute/routeSpec.js +++ b/test/ngRoute/routeSpec.js @@ -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(); + })); });