Skip to content

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.

string

The directory the path must stay inside.

string

The path to check.

PathWithinOptions

Resolution base, root-equality and case-folding policy.

string

The resolved absolute path.

PathEscapeError If the resolved path is outside the resolved root.