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

Function resolvedSegments

src/resolution/frameworks/angular-router.ts:407–419  ·  view source on GitHub ↗

A path's segments with each `{expr}` read from the constant it names, as seen from `file` — where the route (or the mount) is written.

(pathText: string, file: string, context: ResolutionContext)

Source from the content-addressed store, hash-verified

405
406/** A path's segments with each `{expr}` read from the constant it names, as seen from `file` — where the route (or the mount) is written. */
407function resolvedSegments(pathText: string, file: string, context: ResolutionContext): string[] {
408 return pathText
409 .split('/')
410 .filter((seg) => seg.length > 0)
411 .flatMap((seg) => {
412 if (seg.startsWith('{') && seg.endsWith('}') && seg.indexOf('{', 1) < 0) {
413 const value = constantValue(seg.slice(1, -1), file, context);
414 return value === null ? [seg] : value.split('/').filter((v) => v.length > 0);
415 }
416 // `:{ProjectConst.IssueId}` — a constant inside a segment.
417 return [seg.replace(/\{([^{}]+)\}/g, (all, expr: string) => constantValue(expr, file, context) ?? all)];
418 });
419}
420
421/** The class a route's component names, by its import (or this file) — or a lazy import's. */
422function routeComponent(encoded: string, fromFile: string, context: ResolutionContext): Node | null {

Callers 3

prefixOfFunction · 0.85
angularRouteTableFunction · 0.85
resolvedFunction · 0.85

Calls 1

constantValueFunction · 0.70

Tested by

no test coverage detected