Skip to content

Universal DevTools Kit SDK


Universal DevTools Kit SDK / @u-devtools/utils-node / safeResolve

Function: safeResolve() ​

safeResolve(root, targetPath): string

Defined in: path.ts:27

Safely resolves a file path relative to a root directory. Throws an error if the resolved path is outside the root directory.

Parameters ​

ParameterTypeDescription
rootstringThe root directory path
targetPathstringThe target path (relative or absolute)

Returns ​

string

The resolved absolute path

Throws ​

Error if the path is outside the root directory

Released under the MIT License.