Skip to main content

resolveSafeChildPath()

Home > @backstage/backend-common > resolveSafeChildPath

Resolves a target path from a base path while guaranteeing that the result is a path that point to or within the base path. This is useful for resolving paths from user input, as it otherwise opens up for vulnerabilities.

Signature:

function resolveSafeChildPath(base: string, path: string): string;

Parameters

ParameterTypeDescription
basestringThe base directory to resolve the path from.
pathstringThe target path, relative or absolute

Returns:

string

A path that is guaranteed to point to or within the base path.