File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -2593,6 +2593,39 @@ const TESTS: Test[] = [
2593
2593
[ { foo : "#" } , null ] ,
2594
2594
] ,
2595
2595
] ,
2596
+ /**
2597
+ * https://github.com/pillarjs/path-to-regexp/issues/260
2598
+ */
2599
+ [
2600
+ ":name*" ,
2601
+ undefined ,
2602
+ [
2603
+ {
2604
+ name : "name" ,
2605
+ prefix : "" ,
2606
+ suffix : "" ,
2607
+ modifier : "*" ,
2608
+ pattern : "[^\\/#\\?]+?" ,
2609
+ } ,
2610
+ ] ,
2611
+ [ [ "foobar" , [ "foobar" , "foobar" ] ] ] ,
2612
+ [ [ { name : "foobar" } , "foobar" ] ] ,
2613
+ ] ,
2614
+ [
2615
+ ":name+" ,
2616
+ undefined ,
2617
+ [
2618
+ {
2619
+ name : "name" ,
2620
+ prefix : "" ,
2621
+ suffix : "" ,
2622
+ modifier : "+" ,
2623
+ pattern : "[^\\/#\\?]+?" ,
2624
+ } ,
2625
+ ] ,
2626
+ [ [ "foobar" , [ "foobar" , "foobar" ] ] ] ,
2627
+ [ [ { name : "foobar" } , "foobar" ] ] ,
2628
+ ] ,
2596
2629
] ;
2597
2630
2598
2631
/**
Original file line number Diff line number Diff line change @@ -563,7 +563,11 @@ export function tokensToRegexp(
563
563
route += `(?:${ prefix } (${ token . pattern } )${ suffix } )${ token . modifier } ` ;
564
564
}
565
565
} else {
566
- route += `(${ token . pattern } )${ token . modifier } ` ;
566
+ if ( token . modifier === "+" || token . modifier === "*" ) {
567
+ route += `((?:${ token . pattern } )${ token . modifier } )` ;
568
+ } else {
569
+ route += `(${ token . pattern } )${ token . modifier } ` ;
570
+ }
567
571
}
568
572
} else {
569
573
route += `(?:${ prefix } ${ suffix } )${ token . modifier } ` ;
You can’t perform that action at this time.
0 commit comments