A path's segments with each `{expr}` read from the constant it names, as seen from `file` — where the route (or the mount) is written.
(pathText: string, file: string, context: ResolutionContext)
| 405 | |
| 406 | /** A path's segments with each `{expr}` read from the constant it names, as seen from `file` — where the route (or the mount) is written. */ |
| 407 | function resolvedSegments(pathText: string, file: string, context: ResolutionContext): string[] { |
| 408 | return pathText |
| 409 | .split('/') |
| 410 | .filter((seg) => seg.length > 0) |
| 411 | .flatMap((seg) => { |
| 412 | if (seg.startsWith('{') && seg.endsWith('}') && seg.indexOf('{', 1) < 0) { |
| 413 | const value = constantValue(seg.slice(1, -1), file, context); |
| 414 | return value === null ? [seg] : value.split('/').filter((v) => v.length > 0); |
| 415 | } |
| 416 | // `:{ProjectConst.IssueId}` — a constant inside a segment. |
| 417 | return [seg.replace(/\{([^{}]+)\}/g, (all, expr: string) => constantValue(expr, file, context) ?? all)]; |
| 418 | }); |
| 419 | } |
| 420 | |
| 421 | /** The class a route's component names, by its import (or this file) — or a lazy import's. */ |
| 422 | function routeComponent(encoded: string, fromFile: string, context: ResolutionContext): Node | null { |
no test coverage detected