MCPcopy
hub / github.com/21st-dev/1code / resolvePathInWorktree

Function resolvePathInWorktree

src/main/lib/git/security/path-validation.ts:178–186  ·  view source on GitHub ↗
(
	worktreePath: string,
	filePath: string,
	options: ValidatePathOptions = {},
)

Source from the content-addressed store, hash-verified

176 * @throws PathValidationError if path is invalid
177 */
178export function resolvePathInWorktree(
179 worktreePath: string,
180 filePath: string,
181 options: ValidatePathOptions = {},
182): string {
183 validateRelativePath(filePath, options);
184 // Use resolve to handle any worktreePath (relative or absolute)
185 return resolve(worktreePath, normalize(filePath));
186}
187
188/**
189 * Validates a path for git commands. Lighter check that allows root.

Callers 8

readFileFunction · 0.90
readFileBufferFunction · 0.90
writeFileFunction · 0.90
deleteFunction · 0.90
statFunction · 0.90
lstatFunction · 0.90
existsFunction · 0.90
isSymlinkEscapingFunction · 0.90

Calls 1

validateRelativePathFunction · 0.85

Tested by

no test coverage detected