File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -539,9 +539,11 @@ export function tokensToRegexp(
539539 start = true ,
540540 end = true ,
541541 encode = ( x : string ) => x ,
542+ delimiter = "/#?" ,
543+ endsWith = "" ,
542544 } = options ;
543- const endsWith = `[${ escapeString ( options . endsWith || "" ) } ]|$` ;
544- const delimiter = `[${ escapeString ( options . delimiter || "/#?" ) } ]` ;
545+ const endsWithRe = `[${ escapeString ( endsWith ) } ]|$` ;
546+ const delimiterRe = `[${ escapeString ( delimiter ) } ]` ;
545547 let route = start ? "^" : "" ;
546548
547549 // Iterate over the tokens and create our regexp string.
@@ -576,23 +578,23 @@ export function tokensToRegexp(
576578 }
577579
578580 if ( end ) {
579- if ( ! strict ) route += `${ delimiter } ?` ;
581+ if ( ! strict ) route += `${ delimiterRe } ?` ;
580582
581- route += ! options . endsWith ? "$" : `(?=${ endsWith } )` ;
583+ route += ! options . endsWith ? "$" : `(?=${ endsWithRe } )` ;
582584 } else {
583585 const endToken = tokens [ tokens . length - 1 ] ;
584586 const isEndDelimited =
585587 typeof endToken === "string"
586- ? delimiter . indexOf ( endToken [ endToken . length - 1 ] ) > - 1
588+ ? delimiterRe . indexOf ( endToken [ endToken . length - 1 ] ) > - 1
587589 : // tslint:disable-next-line
588590 endToken === undefined ;
589591
590592 if ( ! strict ) {
591- route += `(?:${ delimiter } (?=${ endsWith } ))?` ;
593+ route += `(?:${ delimiterRe } (?=${ endsWithRe } ))?` ;
592594 }
593595
594596 if ( ! isEndDelimited ) {
595- route += `(?=${ delimiter } |${ endsWith } )` ;
597+ route += `(?=${ delimiterRe } |${ endsWithRe } )` ;
596598 }
597599 }
598600
You can’t perform that action at this time.
0 commit comments