fix: consolidate boundary ownership and cleanup failure paths (#477)
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import { isAbsolute, relative, sep } from "node:path";
|
||||
|
||||
/** Test lexical containment on the host platform; callers must resolve symlinks first. */
|
||||
export const isPathWithinRoot = (root: string, path: string): boolean => {
|
||||
const value = relative(root, path);
|
||||
return (
|
||||
value === "" ||
|
||||
(value !== ".." && !value.startsWith(`..${sep}`) && !isAbsolute(value))
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user