Skip to content

Commit 90bf6f3

Browse files
committed
refactor(matcher): parser should throw on invalid path
1 parent 960d9ad commit 90bf6f3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/matcher/pathTokenizer.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ const VALID_PARAM_RE = /[a-zA-Z0-9_]/
4646
export function tokenizePath(path: string): Array<Token[]> {
4747
if (!path) return [[]]
4848
if (path === '/') return [[ROOT_TOKEN]]
49-
// remove the leading slash
50-
if (__DEV__ && !path.startsWith('/')) {
49+
if (!path.startsWith('/')) {
5150
throw new Error(
52-
`Route path should start with a "/": "${path}" should be "/${path}". This will break in production.`
51+
__DEV__
52+
? `Route paths should start with a "/": "${path}" should be "/${path}".`
53+
: `Invalid path "${path}"`
5354
)
5455
}
5556

0 commit comments

Comments
 (0)