MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / resolveWorkspacePath

Function resolveWorkspacePath

compatible-shell/src/tools.mjs:379–389  ·  view source on GitHub ↗
(workspaceDir, requestedPath)

Source from the content-addressed store, hash-verified

377}
378
379function resolveWorkspacePath(workspaceDir, requestedPath) {
380 const absoluteWorkspace = path.resolve(workspaceDir)
381 const candidate = path.resolve(absoluteWorkspace, requestedPath)
382 const relative = path.relative(absoluteWorkspace, candidate)
383
384 if (relative.startsWith('..') || path.isAbsolute(relative)) {
385 throw new Error(`Path escapes workspace: ${requestedPath}`)
386 }
387
388 return candidate
389}
390
391function toWorkspaceRelative(workspaceDir, absolutePath) {
392 const relative = path.relative(workspaceDir, absolutePath)

Callers 4

listDirFunction · 0.85
readFileFunction · 0.85
writeFileFunction · 0.85
searchTextFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected