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

Commit fd6ff1b

Browse files
committed
fixup! fix($route): correctly extract path params if path contains question mark or hash
1 parent 3dc24b2 commit fd6ff1b

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

test/ngRoute/routeParamsSpec.js

+24-3
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,41 @@ describe('$routeParams', function() {
8080
it('should correctly extract path params containing hashes and/or question marks', function() {
8181
module(function($routeProvider) {
8282
$routeProvider.when('/foo/:bar', {});
83+
$routeProvider.when('/zoo/:bar/:baz/:qux', {});
8384
});
8485

85-
inject(function($rootScope, $route, $location, $routeParams) {
86+
inject(function($location, $rootScope, $routeParams) {
87+
$location.path('/foo/bar?baz');
88+
$rootScope.$digest();
89+
expect($routeParams).toEqual({bar: 'bar?baz'});
90+
91+
$location.path('/foo/bar?baz=val');
92+
$rootScope.$digest();
93+
expect($routeParams).toEqual({bar: 'bar?baz=val'});
94+
8695
$location.path('/foo/bar#baz');
8796
$rootScope.$digest();
8897
expect($routeParams).toEqual({bar: 'bar#baz'});
8998

90-
$location.path('/foo/bar?baz');
99+
$location.path('/foo/bar?baz#qux');
91100
$rootScope.$digest();
92-
expect($routeParams).toEqual({bar: 'bar?baz'});
101+
expect($routeParams).toEqual({bar: 'bar?baz#qux'});
102+
103+
$location.path('/foo/bar?baz=val#qux');
104+
$rootScope.$digest();
105+
expect($routeParams).toEqual({bar: 'bar?baz=val#qux'});
93106

94107
$location.path('/foo/bar#baz?qux');
95108
$rootScope.$digest();
96109
expect($routeParams).toEqual({bar: 'bar#baz?qux'});
110+
111+
$location.path('/zoo/bar?p1=v1#h1/baz?p2=v2#h2/qux?p3=v3#h3');
112+
$rootScope.$digest();
113+
expect($routeParams).toEqual({
114+
bar: 'bar?p1=v1#h1',
115+
baz: 'baz?p2=v2#h2',
116+
qux: 'qux?p3=v3#h3'
117+
});
97118
});
98119
});
99120

0 commit comments

Comments
 (0)