Skip to content

resolveFrom ​

The resolveFrom() function resolves a list of segments from an origin and returns an absolute path or null. It resolves segments in order using resolveRelative and validates that the final path is absolute.

WARNING

Works only with POSIX paths (not Windows paths).

Interactive example ​

Syntax ​

typescript
function resolveFrom<
    GenericSegment extends string,
>(
    origin: string,
    segments: AnyTuple<GenericSegment>,
    params?: {
        stayInOrigin?: boolean;
    },
): string | null;

Parameters ​

  • origin : The origin path.
  • segments : Array of segments to resolve.
  • params.stayInOrigin : When true, returns null if segments would escape the origin.

Return value ​

The resolved absolute path, or null when the result is not absolute (or when stayInOrigin blocks traversal).

See also ​

Released under the MIT license.