The address a code-based route sits at, following `getParentRoute` up.
(
name: string,
decls: Map<string, { path: string | null; parent: string | null }>
)
| 238 | |
| 239 | /** The address a code-based route sits at, following `getParentRoute` up. */ |
| 240 | function composePath( |
| 241 | name: string, |
| 242 | decls: Map<string, { path: string | null; parent: string | null }> |
| 243 | ): string | null { |
| 244 | const segs: string[] = []; |
| 245 | let cur: string | null = name; |
| 246 | for (let hops = 0; cur !== null && hops < 24; hops++) { |
| 247 | const decl: { path: string | null; parent: string | null } | undefined = decls.get(cur); |
| 248 | if (!decl) return null; // a parent declared in another file — not composed |
| 249 | if (decl.path !== null) { |
| 250 | const own = decl.path.split('/').filter((s) => s.length > 0); |
| 251 | segs.unshift(...own); |
| 252 | } |
| 253 | cur = decl.parent; |
| 254 | } |
| 255 | return '/' + segs.join('/'); |
| 256 | } |
| 257 | |
| 258 | /** |
| 259 | * The text of the call chain starting at `at` — `({ … })`, and any `.update({ … })` |
no test coverage detected