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

Function lexicalPathWithinRoot

src/utils.ts:96–99  ·  view source on GitHub ↗
(projectRoot: string, filePath: string)

Source from the content-addressed store, hash-verified

94 * contents get served — those must keep the symlink-aware check (#527).
95 */
96export function lexicalPathWithinRoot(projectRoot: string, filePath: string): string | null {
97 const resolved = path.resolve(projectRoot, filePath);
98 return isWithinDir(resolved, path.resolve(projectRoot)) ? resolved : null;
99}
100
101/**
102 * Validate that a file path stays within the project root, resolving symlinks.

Callers 2

createContextMethod · 0.90
validatePathWithinRootFunction · 0.85

Calls 2

isWithinDirFunction · 0.85
resolveMethod · 0.65

Tested by

no test coverage detected