joinPathUnderRoot
Callable
Parameters
root: string
The directory the result must stay in.
path: string
The path to join to the root.
Returns string
The normalized path, or undefined when it is outside the root.
The directory the result must stay in.
The path to join to the root.
The normalized path, or undefined when it is outside the root.
Joins a path to a root directory and returns the result only when it stays inside that root.
Unlike
resolvePathUnder(), the path is always relative to the root, even with a leading slash, and the root itself is a valid result. This matches how a web server maps a URL path to its document root.