Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fd6bac7

Browse files
committed
fix(ngRoute): pipe preceding route param no longer masks ? or * operator
Before this change, ```js $routeProvider.when('/foo/:bar|?', { ... }); ``` would not have the expected effect --- the parameter would not be optional, and the pipe would not be included in the parameter name. Following this change, the presence of the pipe operator will typically cause an exception to be thrown due to the fact that the generated regexp is invalid. The net result of this change is that ? and * operators will not be masked, and pipe operators will need to be removed, although it's unexpected that these are being used anywhere. Closes angular#5920
1 parent 6d525f0 commit fd6bac7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/ngRoute/route.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ function $RouteProvider(){
185185

186186
path = path
187187
.replace(/([().])/g, '\\$1')
188-
.replace(/(\/)?:(\w+)([\?|\*])?/g, function(_, slash, key, option){
188+
.replace(/(\/)?:(\w+)([\?\*])?/g, function(_, slash, key, option){
189189
var optional = option === '?' ? option : null;
190190
var star = option === '*' ? option : null;
191191
keys.push({ name: key, optional: !!optional });

0 commit comments

Comments
 (0)