MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / composePath

Function composePath

src/resolution/frameworks/tanstack-router.ts:319–335  ·  view source on GitHub ↗

The address a code-based route sits at, following `getParentRoute` up.

(
  name: string,
  decls: Map<string, { path: string | null; parent: string | null }>
)

Source from the content-addressed store, hash-verified

317
318/** The address a code-based route sits at, following `getParentRoute` up. */
319function composePath(
320 name: string,
321 decls: Map<string, { path: string | null; parent: string | null }>
322): string | null {
323 const segs: string[] = [];
324 let cur: string | null = name;
325 for (let hops = 0; cur !== null && hops < 24; hops++) {
326 const decl: { path: string | null; parent: string | null } | undefined = decls.get(cur);
327 if (!decl) return null; // a parent declared in another file — not composed
328 if (decl.path !== null) {
329 const own = decl.path.split('/').filter((s) => s.length > 0);
330 segs.unshift(...own);
331 }
332 cur = decl.parent;
333 }
334 return '/' + segs.join('/');
335}
336
337/**
338 * The text of the call chain starting at `at` — `({ … })`, and any `.update({ … })`

Callers 1

parseTanstackRoutesFunction · 0.85

Calls 2

getMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected