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

Function isWithinDir

src/utils.ts:103–108  ·  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

101 * case than the lexical root, which would otherwise false-reject a valid file.
102 */
103function isWithinDir(child: string, parent: string): boolean {
104 if (process.platform === 'win32') {
105 return isSameOrUnder(child.toLowerCase(), parent.toLowerCase());
106 }
107 return isSameOrUnder(child, parent);
108}
109
110/**
111 * 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