MCPcopy Create free account
hub / github.com/SethGammon/Citadel / isUnderRoot

Function isUnderRoot

hooks_src/organize-enforce.js:85–89  ·  view source on GitHub ↗

* Check if a file path is under a given root directory.

(filePath, rootPath)

Source from the content-addressed store, hash-verified

83 * Check if a file path is under a given root directory.
84 */
85function isUnderRoot(filePath, rootPath) {
86 const normalizedFile = filePath.replace(/\\/g, '/');
87 const normalizedRoot = rootPath.replace(/\\/g, '/').replace(/\/$/, '') + '/';
88 return normalizedFile.startsWith(normalizedRoot);
89}
90
91/**
92 * Get the directory of a file path, normalized to forward slashes.

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected