fix: resolve paths in validation for Windows compatibility

normalizeForCompare and isPathWithinRoot now use path.resolve()
to ensure consistent drive-letter prefix on Windows. Previously
path.normalize('/foo') gave '\foo' (no drive letter) while
path.resolve('/foo') gives 'C:\foo', causing containment checks
to fail on Windows CI.
This commit is contained in:
iliya 2026-03-01 08:12:55 +02:00
parent ccee484adc
commit 20d563d737

View file

@ -62,12 +62,14 @@ export interface PathValidationResult {
}
function normalizeForCompare(input: string, isWindows: boolean): string {
const normalized = path.normalize(input);
const normalized = path.resolve(path.normalize(input));
return isWindows ? normalized.toLowerCase() : normalized;
}
export function isPathWithinRoot(targetPath: string, rootPath: string): boolean {
return targetPath === rootPath || targetPath.startsWith(rootPath + path.sep);
const target = path.resolve(targetPath);
const root = path.resolve(rootPath);
return target === root || target.startsWith(root + path.sep);
}
function resolveRealPathIfExists(inputPath: string): string | null {