Skip to content

Commit bac68cd

Browse files
committed
final nitpicks
1 parent 16db1a5 commit bac68cd

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/router-generator/src/utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export function removeTrailingSlash(s: string) {
5353
}
5454

5555
const BRACKET_CONTENT_RE = /\[(.*?)\]/g
56+
const SPLIT_REGEX = /(?<!\[)\.(?!\])/g
5657

5758
export 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

packages/router-generator/tests/utils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ describe('removeLeadingUnderscores', () => {
263263
})
264264

265265
describe('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(

0 commit comments

Comments
 (0)