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

Function parseRoute

packages/onboarding-demo/src/next-flow.tsx:44–56  ·  view source on GitHub ↗
(hash: string)

Source from the content-addressed store, hash-verified

42 | { readonly kind: "auth"; readonly domain: string };
43
44const parseRoute = (hash: string): NextRoute => {
45 // `#reworked/...` is canonical; `#next/...` is kept working because it was
46 // the first spelling and may already be pasted somewhere.
47 const path = hash.replace(/^#/, "").replace(/^(reworked|next)\/?/, "");
48 const segments = path.split("/").filter((segment) => segment.length > 0);
49 if (segments.length === 0) return { kind: "browse" };
50 const [first, second] = segments;
51 if (first === "installed") return { kind: "installed" };
52 if (first === "custom") return { kind: "custom" };
53 if (first && second === "auth") return { kind: "auth", domain: first };
54 if (first) return { kind: "detail", domain: first };
55 return { kind: "browse" };
56};
57
58const routeToHash = (route: NextRoute): string => {
59 if (route.kind === "browse") return "#reworked";

Callers 2

NextFlowFunction · 0.85
onHashChangeFunction · 0.85

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected