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

Function hrefSegments

src/resolution/frameworks/nextjs.ts:154–164  ·  view source on GitHub ↗

`/users/${…}?tab=x` → `['users', '*']`; an absolute URL keeps its path; a relative href is nothing.

(href: HrefLiteral)

Source from the content-addressed store, hash-verified

152
153/** `/users/${…}?tab=x` → `['users', '*']`; an absolute URL keeps its path; a relative href is nothing. */
154function hrefSegments(href: HrefLiteral): string[] | null {
155 let p = href.path;
156 const absolute = /^(?:[a-z][a-z0-9+.-]*:)?\/\/[^/]*(\/.*)?$/i.exec(p);
157 if (absolute) p = absolute[1] ?? '/';
158 if (!p.startsWith('/')) return null;
159 return p
160 .split('/')
161 .slice(1)
162 .filter((s) => s.length > 0)
163 .map((s) => (s.includes(HOLE) ? '*' : decode(s)));
164}
165
166function decode(s: string): string {
167 try {

Callers 1

destinationsForHrefFunction · 0.85

Calls 3

decodeFunction · 0.85
mapMethod · 0.80
execMethod · 0.65

Tested by

no test coverage detected