The address a code-based route sits at, following `getParentRoute` up.
(
name: string,
decls: Map<string, { path: string | null; parent: string | null }>
)
| 317 | |
| 318 | /** The address a code-based route sits at, following `getParentRoute` up. */ |
| 319 | function composePath( |
| 320 | name: string, |
| 321 | decls: Map<string, { path: string | null; parent: string | null }> |
| 322 | ): string | null { |
| 323 | const segs: string[] = []; |
| 324 | let cur: string | null = name; |
| 325 | for (let hops = 0; cur !== null && hops < 24; hops++) { |
| 326 | const decl: { path: string | null; parent: string | null } | undefined = decls.get(cur); |
| 327 | if (!decl) return null; // a parent declared in another file — not composed |
| 328 | if (decl.path !== null) { |
| 329 | const own = decl.path.split('/').filter((s) => s.length > 0); |
| 330 | segs.unshift(...own); |
| 331 | } |
| 332 | cur = decl.parent; |
| 333 | } |
| 334 | return '/' + segs.join('/'); |
| 335 | } |
| 336 | |
| 337 | /** |
| 338 | * The text of the call chain starting at `at` — `({ … })`, and any `.update({ … })` |
no test coverage detected