fix(windows): normalize namespaced path containment checks

This commit is contained in:
Shakker
2026-02-26 18:49:26 +00:00
parent dc6e4a5b13
commit f7041fbee3
6 changed files with 45 additions and 13 deletions

View File

@@ -1,12 +1,8 @@
import fs from "node:fs";
import path from "node:path";
import { isPathInside as isBoundaryPathInside } from "../infra/path-guards.js";
export function isPathInside(baseDir: string, targetPath: string): boolean {
const rel = path.relative(baseDir, targetPath);
if (!rel) {
return true;
}
return !rel.startsWith("..") && !path.isAbsolute(rel);
return isBoundaryPathInside(baseDir, targetPath);
}
export function safeRealpathSync(targetPath: string, cache?: Map<string, string>): string | null {