मुख्य कंटेंट तक स्किप करें

joinPathUnderRoot

Callable

  • joinPathUnderRoot(root: string, path: string): string

  • 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.


    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.