(route: unknown, parentId = "")
| 10 | // lack a route that this package's pages link to. Lock them together. |
| 11 | |
| 12 | const collectPaths = (route: unknown, parentId = ""): ReadonlyArray<string> => { |
| 13 | const node = route as { |
| 14 | options?: { id?: string }; |
| 15 | children?: ReadonlyArray<unknown>; |
| 16 | }; |
| 17 | const children = node.children ?? []; |
| 18 | const id = node.options?.id; |
| 19 | const resolved = |
| 20 | typeof id === "string" |
| 21 | ? parentId && !id.startsWith(`/${ORG_SLUG_SEGMENT}`) |
| 22 | ? `${parentId.replace(/\/$/, "")}${id}` |
| 23 | : id |
| 24 | : parentId; |
| 25 | const own = typeof id === "string" ? [resolved] : []; |
| 26 | return [...own, ...children.flatMap((child) => collectPaths(child, resolved))]; |
| 27 | }; |
| 28 | |
| 29 | // The generated ids are the scope-relative contract paths nested under the |
| 30 | // optional org-slug segment ("/policies" -> "/{-$orgSlug}/policies"). |
no test coverage detected