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

Function composeRoutePath

src/resolution/frameworks/react.ts:290–297  ·  view source on GitHub ↗

React Router's nesting: a child path is relative unless it starts with `/`.

(parts: string[])

Source from the content-addressed store, hash-verified

288
289/** React Router's nesting: a child path is relative unless it starts with `/`. */
290function composeRoutePath(parts: string[]): string {
291 let path = '';
292 for (const part of parts) {
293 if (part.startsWith('/')) path = part;
294 else if (part) path = `${path.replace(/\/+$/, '')}/${part}`;
295 }
296 return ('/' + path.replace(/^\/+/, '')).replace(/\/{2,}/g, '/').replace(/(.)\/$/, '$1');
297}
298
299/**
300 * The string a member expression like `paths.app.root.path` reads from a

Callers 3

postExtractFunction · 0.85
scanRoutesFunction · 0.85
tableRoutesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected