File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed
packages/router-generator Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ export function removeTrailingSlash(s: string) {
5353}
5454
5555const BRACKET_CONTENT_RE = / \[ ( .* ?) \] / g
56+ const SPLIT_REGEX = / (?< ! \[ ) \. (? ! \] ) / g
5657
5758export function determineInitialRoutePath (
5859 routePath : string ,
@@ -73,11 +74,10 @@ export function determineInitialRoutePath(
7374 '%' ,
7475 ] )
7576
76- const splitRegex = / (?< ! \[ ) \. (? ! \] ) / g
77-
7877 const originalRoutePath =
79- cleanPath ( `/${ ( cleanPath ( routePath ) || '' ) . split ( splitRegex ) . join ( '/' ) } ` ) ||
80- ''
78+ cleanPath (
79+ `/${ ( cleanPath ( routePath ) || '' ) . split ( SPLIT_REGEX ) . join ( '/' ) } ` ,
80+ ) || ''
8181
8282 // check if the route path is a valid non-nested path,
8383 // TODO with new major rename to reflect not experimental anymore
@@ -103,7 +103,7 @@ export function determineInitialRoutePath(
103103 }
104104 }
105105
106- const parts = cleanedRoutePath . split ( splitRegex )
106+ const parts = cleanedRoutePath . split ( SPLIT_REGEX )
107107
108108 // Escape any characters that in square brackets
109109 // we keep the original path untouched
Original file line number Diff line number Diff line change @@ -263,7 +263,7 @@ describe('removeLeadingUnderscores', () => {
263263} )
264264
265265describe ( 'removeTrailingUnderscores' , ( ) => {
266- it ( 'removes leading underscore when nonnested path' , ( ) => {
266+ it ( 'removes trailing underscore when nonnested path' , ( ) => {
267267 expect ( removeTrailingUnderscores ( 'test_' , 'route' ) ) . toBe ( 'test' )
268268
269269 expect ( removeTrailingUnderscores ( '/_test_/abc_/route/_d' , 'route' ) ) . toBe (
You can’t perform that action at this time.
0 commit comments