MCPcopy Create free account
hub / github.com/anus-dev/ANUS / validateImportPath

Function validateImportPath

packages/core/src/utils/memoryImportProcessor.ts:404–419  ·  view source on GitHub ↗
(
  importPath: string,
  basePath: string,
  allowedDirectories: string[],
)

Source from the content-addressed store, hash-verified

402}
403
404export function validateImportPath(
405 importPath: string,
406 basePath: string,
407 allowedDirectories: string[],
408): boolean {
409 // Reject URLs
410 if (/^(file|https?):\/\//.test(importPath)) {
411 return false;
412 }
413
414 const resolvedPath = path.resolve(basePath, importPath);
415
416 return allowedDirectories.some((allowedDir) =>
417 isSubpath(allowedDir, resolvedPath),
418 );
419}

Callers 3

processFlatFunction · 0.85
processImportsFunction · 0.85

Calls 1

isSubpathFunction · 0.85

Tested by

no test coverage detected