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

Function collectPaths

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

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected