chore: throw when three dot character is detected in segment (#67348)
### Why? It could be confusing between `...` and `…`, which the later is actually a single character. ### How? We throw if we detect `…` instead of `...`.
This commit is contained in:
parent
78dc2db916
commit
f702a14acf
2 changed files with 12 additions and 0 deletions
|
@ -94,6 +94,12 @@ class UrlNode {
|
|||
isOptional = true
|
||||
}
|
||||
|
||||
if (segmentName.startsWith('…')) {
|
||||
throw new Error(
|
||||
`Detected a three-dot character ('…') at ('${segmentName}'). Did you mean ('...')?`
|
||||
)
|
||||
}
|
||||
|
||||
if (segmentName.startsWith('...')) {
|
||||
// Strip `...`, leaving only `something`
|
||||
segmentName = segmentName.substring(3)
|
||||
|
|
|
@ -213,4 +213,10 @@ describe('getSortedRoutes', () => {
|
|||
])
|
||||
).toThrow(/differ only by non-word/)
|
||||
})
|
||||
|
||||
it('catches param names start with three-dot character not actual three dots', () => {
|
||||
expect(() => getSortedRoutes(['[…three-dots]'])).toThrow(
|
||||
/Detected a three-dot character/
|
||||
)
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue