MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / collectPaths

Function collectPaths

packages/react/src/console-routes.test.ts:12–27  ·  view source on GitHub ↗
(route: unknown, parentId = "")

Source from the content-addressed store, hash-verified

10// lack a route that this package's pages link to. Lock them together.
11
12const 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").

Callers 1

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected