mirror of
https://github.com/C4illin/ConvertX.git
synced 2026-09-13 02:14:32 +02:00
7 lines
276 B
TypeScript
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);
|
|
};
|