MCPcopy Index your code
hub / github.com/coder/mux / isPathInsideDir

Function isPathInsideDir

src/node/services/gitPatchArtifactService.ts:46–53  ·  view source on GitHub ↗
(dirPath: string, filePath: string)

Source from the content-addressed store, hash-verified

44export type OnPatchGenerationComplete = (childWorkspaceId: string) => Promise<void>;
45
46function isPathInsideDir(dirPath: string, filePath: string): boolean {
47 const resolvedDir = path.resolve(dirPath);
48 const resolvedFile = path.resolve(filePath);
49 const relativePath = path.relative(resolvedDir, resolvedFile);
50 return (
51 relativePath.length > 0 && !relativePath.startsWith("..") && !path.isAbsolute(relativePath)
52 );
53}
54
55async function writeReadableStreamToLocalFile(
56 stream: ReadableStream<Uint8Array>,

Callers 1

generateMethod · 0.70

Calls 3

resolveMethod · 0.80
relativeMethod · 0.80
isAbsoluteMethod · 0.80

Tested by

no test coverage detected