mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-06-11 15:52:50 +08:00
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
This commit is contained in:
committed by
Peter Bacon Darwin
parent
49b2a1c8cf
commit
1b779028fd
@@ -468,9 +468,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;
|
||||
|
||||
@@ -219,13 +219,13 @@ describe('$route', function() {
|
||||
expect($route.current).toBeUndefined();
|
||||
}));
|
||||
|
||||
it('matches literal .', inject(function($route, $location, $rootScope) {
|
||||
it('matches literal *', inject(function($route, $location, $rootScope) {
|
||||
$location.path('/$testX23/foo*(bar)/222');
|
||||
$rootScope.$digest();
|
||||
expect($route.current).toBeUndefined();
|
||||
}));
|
||||
|
||||
it('matches literal *', inject(function($route, $location, $rootScope) {
|
||||
it('matches literal .', inject(function($route, $location, $rootScope) {
|
||||
$location.path('/$test.23/foooo(bar)/222');
|
||||
$rootScope.$digest();
|
||||
expect($route.current).toBeUndefined();
|
||||
@@ -238,7 +238,7 @@ describe('$route', function() {
|
||||
}));
|
||||
|
||||
it('matches a URL with special chars', inject(function($route, $location, $rootScope) {
|
||||
$location.path('/$test.23/foo*(bar)/222');
|
||||
$location.path('/$test.23/foo*(bar)/~!@#$%^&*()_+=-`');
|
||||
$rootScope.$digest();
|
||||
expect($route.current).toBeDefined();
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user