MCPcopy Index your code
hub / github.com/codeaashu/claude-code / isProjectDirPath

Function isProjectDirPath

src/utils/permissions/filesystem.ts:284–291  ·  view source on GitHub ↗

* Check if file is within the current project's directory. * Path format: ~/.claude/projects/{sanitized-cwd}/...

(absolutePath: string)

Source from the content-addressed store, hash-verified

282 * Path format: ~/.claude/projects/{sanitized-cwd}/...
283 */
284function isProjectDirPath(absolutePath: string): boolean {
285 const projectDir = getProjectDir(getCwd())
286 // SECURITY: Normalize to prevent path traversal bypasses via .. segments
287 const normalizedPath = normalize(absolutePath)
288 return (
289 normalizedPath === projectDir || normalizedPath.startsWith(projectDir + sep)
290 )
291}
292
293/**
294 * Checks if the scratchpad directory feature is enabled.

Callers 1

Calls 3

getCwdFunction · 0.85
getProjectDirFunction · 0.50
normalizeFunction · 0.50

Tested by

no test coverage detected