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(
539
539
start = true ,
540
540
end = true ,
541
541
encode = ( x : string ) => x ,
542
+ delimiter = "/#?" ,
543
+ endsWith = "" ,
542
544
} = options ;
543
- const endsWith = `[${ escapeString ( options . endsWith || "" ) } ]|$` ;
544
- const delimiter = `[${ escapeString ( options . delimiter || "/#?" ) } ]` ;
545
+ const endsWithRe = `[${ escapeString ( endsWith ) } ]|$` ;
546
+ const delimiterRe = `[${ escapeString ( delimiter ) } ]` ;
545
547
let route = start ? "^" : "" ;
546
548
547
549
// Iterate over the tokens and create our regexp string.
@@ -576,23 +578,23 @@ export function tokensToRegexp(
576
578
}
577
579
578
580
if ( end ) {
579
- if ( ! strict ) route += `${ delimiter } ?` ;
581
+ if ( ! strict ) route += `${ delimiterRe } ?` ;
580
582
581
- route += ! options . endsWith ? "$" : `(?=${ endsWith } )` ;
583
+ route += ! options . endsWith ? "$" : `(?=${ endsWithRe } )` ;
582
584
} else {
583
585
const endToken = tokens [ tokens . length - 1 ] ;
584
586
const isEndDelimited =
585
587
typeof endToken === "string"
586
- ? delimiter . indexOf ( endToken [ endToken . length - 1 ] ) > - 1
588
+ ? delimiterRe . indexOf ( endToken [ endToken . length - 1 ] ) > - 1
587
589
: // tslint:disable-next-line
588
590
endToken === undefined ;
589
591
590
592
if ( ! strict ) {
591
- route += `(?:${ delimiter } (?=${ endsWith } ))?` ;
593
+ route += `(?:${ delimiterRe } (?=${ endsWithRe } ))?` ;
592
594
}
593
595
594
596
if ( ! isEndDelimited ) {
595
- route += `(?=${ delimiter } |${ endsWith } )` ;
597
+ route += `(?=${ delimiterRe } |${ endsWithRe } )` ;
596
598
}
597
599
}
598
600
You can’t perform that action at this time.
0 commit comments