Files
ConvertX/src/helpers/validatePath.ts
T
2026-03-24 22:02:33 +01:00

7 lines
276 B
TypeScript

import path from "node:path";
export const isSafePath = (expectedParent: string, userInput: string): boolean => {
const relativePath = path.relative(expectedParent, userInput);
return !!relativePath && !relativePath.startsWith("..") && !path.isAbsolute(relativePath);
};