rdme
Version:
ReadMe's official CLI and GitHub Action.
18 lines (17 loc) • 670 B
TypeScript
/**
* Determine if a URL path segment is safe to use as a filesystem path component, preventing us
* from treating a path segment as a potential directory traversal attack.
*
*/
export declare function isSafePathSegment(segment: unknown): boolean;
/**
* Decode the last path segment of a URI and validate it as a safe path component.
*
*/
export declare function decodeURILastSegment(uri: string): string | null;
/**
* Resolve the segments of a supplied path within a root directory and only return the path if it
* is contained within the supplied root.
*
*/
export declare function resolvePathWithinRoot(root: string, ...segments: string[]): string | null;