* Addresses a route serves, one of each shape: a parameter is a segment no * literal stands for, so `/blog/featured` doesn't cover `/blog/[slug]` (a * `blog/featured` page would own that address), and the route's name writes * `[...all]` and `[[...all]]` alike as `:all*`, so the file says which m
(path: string, routeFile: string)
| 308 | * empty. |
| 309 | */ |
| 310 | function routeAddresses(path: string, routeFile: string): string[] { |
| 311 | const segments = path.split('/').filter(Boolean); |
| 312 | const filled = segments.map((segment) => (segment.startsWith(':') ? ANY_SEGMENT : segment)); |
| 313 | const addresses = [`/${filled.join('/')}`]; |
| 314 | const last = segments[segments.length - 1]; |
| 315 | if (last?.endsWith('*') && routeFile.includes(`[[...${last.slice(1, -1)}]]`)) { |
| 316 | addresses.push(`/${filled.slice(0, -1).join('/')}`); |
| 317 | } |
| 318 | return addresses; |
| 319 | } |
| 320 | |
| 321 | /** Whether a compiled matcher entry accepts an address the route serves. */ |
| 322 | export function matcherCovers(matcher: RegExp, routePath: string, routeFile: string): boolean { |
no test coverage detected