mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-24 03:55:49 +08:00
fix($route): fix redirection with optional/eager params
Previously, when (automatically) redirecting from path that fetured a trailing slash and optional or "eager" parameters, the resulting path would (incorrectly) contain the special characters (`?`,`*`) along with the parameter values. Closes #9819 Closes #9827
This commit is contained in:
committed by
Pawel Kozlowski
parent
93552fed1c
commit
891acf4c20
@@ -974,6 +974,29 @@ describe('$route', function() {
|
||||
});
|
||||
|
||||
|
||||
it('should properly interpolate optional and eager route vars ' +
|
||||
'when redirecting from path with trailing slash', function() {
|
||||
module(function($routeProvider) {
|
||||
$routeProvider.when('/foo/:id?/:subid?', {templateUrl: 'foo.html'});
|
||||
$routeProvider.when('/bar/:id*/:subid', {templateUrl: 'bar.html'});
|
||||
});
|
||||
|
||||
inject(function($location, $rootScope, $route) {
|
||||
$location.path('/foo/id1/subid2/');
|
||||
$rootScope.$digest();
|
||||
|
||||
expect($location.path()).toEqual('/foo/id1/subid2');
|
||||
expect($route.current.templateUrl).toEqual('foo.html');
|
||||
|
||||
$location.path('/bar/id1/extra/subid2/');
|
||||
$rootScope.$digest();
|
||||
|
||||
expect($location.path()).toEqual('/bar/id1/extra/subid2');
|
||||
expect($route.current.templateUrl).toEqual('bar.html');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should allow custom redirectTo function to be used', function() {
|
||||
function customRedirectFn(routePathParams, path, search) {
|
||||
expect(routePathParams).toEqual({id: 'id3'});
|
||||
|
||||
Reference in New Issue
Block a user