assertPathWithin
assertPathWithin(
root,path,options?):string
Defined in: packages/node/src/fs/path-within.ts:251
Require that path stays inside root, and hand back the resolved path.
Returning the resolved path is the point: a caller that resolves again to use it opens a second window in which the answer could change, and a caller that uses its original relative input has not used the thing that was checked.
Same textual semantics as isPathWithin, symbolic links included.
Parameters
Section titled “Parameters”string
The directory the path must stay inside.
string
The path to check.
options?
Section titled “options?”Resolution base, root-equality and case-folding policy.
Returns
Section titled “Returns”string
The resolved absolute path.
Throws
Section titled “Throws”PathEscapeError If the resolved path is outside the resolved root.