File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -4,8 +4,10 @@ export function routeToRegExp(route: string = "/"): RegExp {
44 if ( ! segment ) continue ;
55 if ( segment === "*" ) {
66 reSegments . push ( "[^/]*" ) ;
7- } else if ( segment === "**" ) {
8- reSegments . push ( "?(?<_>.*)" ) ;
7+ } else if ( segment . startsWith ( "**" ) ) {
8+ reSegments . push (
9+ segment === "**" ? "?(?<_>.*)" : `?(?<${ segment . slice ( 3 ) } >.+)` ,
10+ ) ;
911 } else if ( segment . includes ( ":" ) ) {
1012 reSegments . push (
1113 segment
Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ describe("routeToRegExp", () => {
3636 [ "/path/anything/more" , { _ : "anything/more" } ] ,
3737 ] ,
3838 } ,
39+ "/base/**:path" : {
40+ regex : / ^ \/ b a s e \/ ? (?< path > .+ ) \/ ? $ / ,
41+ match : [ [ "/base/anything/more" , { path : "anything/more" } ] ] ,
42+ } ,
3943 } as const ;
4044
4145 for ( const [ route , expected ] of Object . entries ( routes ) ) {
You can’t perform that action at this time.
0 commit comments