Resolves requested (relative to root, or absolute) to an absolute path
guaranteed to lie inside root.
The lexical check alone is not enough: a symlink inside the root can point
outside it. So after resolving, the deepest existing ancestor is
realpath-ed and containment is checked again. Do not remove that step.
Parameters
root: string
requested: string
Returns Promise<string>
Throws
if the path escapes the root, lexically or via a symlink.
Resolves
requested(relative toroot, or absolute) to an absolute path guaranteed to lie insideroot.The lexical check alone is not enough: a symlink inside the root can point outside it. So after resolving, the deepest existing ancestor is
realpath-ed and containment is checked again. Do not remove that step.