MCPcopy Create free account
hub / github.com/PatrickSys/codebase-context / isWithinRoot

Function isWithinRoot

src/core/symbol-references.ts:72–76  ·  view source on GitHub ↗
(candidate: string)

Source from the content-addressed store, hash-verified

70function resolveAbsoluteChunkPath(rootPath: string, chunk: IndexedChunk): string | null {
71 const resolvedRoot = path.resolve(rootPath);
72 const isWithinRoot = (candidate: string): boolean => {
73 const resolvedCandidate = path.resolve(candidate);
74 const relative = path.relative(resolvedRoot, resolvedCandidate);
75 return Boolean(relative) && !relative.startsWith('..') && !path.isAbsolute(relative);
76 };
77
78 if (typeof chunk.filePath === 'string' && chunk.filePath.trim()) {
79 const raw = chunk.filePath.trim();

Callers 1

resolveAbsoluteChunkPathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected