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

Function isWithinDir

src/utils.ts:104–109  ·  view source on GitHub ↗

* Whether `child` is `parent` itself or sits underneath it. Case-insensitive on * Windows — NTFS is case-insensitive, and realpathSync can hand back a different * case than the lexical root, which would otherwise false-reject a valid file.

(child: string, parent: string)

Source from the content-addressed store, hash-verified

102 * case than the lexical root, which would otherwise false-reject a valid file.
103 */
104function isWithinDir(child: string, parent: string): boolean {
105 if (process.platform === 'win32') {
106 return isSameOrUnder(child.toLowerCase(), parent.toLowerCase());
107 }
108 return isSameOrUnder(child, parent);
109}
110
111/**
112 * The lexical half of {@link validatePathWithinRoot}, on its own.

Callers 2

lexicalPathWithinRootFunction · 0.85
validatePathWithinRootFunction · 0.85

Calls 1

isSameOrUnderFunction · 0.85

Tested by

no test coverage detected