Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Functions

absoluteFilePath

  • absoluteFilePath(path: string): string
  • Resolves a path to its absolute form. Absolute inputs will not be changed (except changing Windows to POSIX). Relative inputs will be interpreted relative to process.cwd().

    Parameters

    • path: string

      Path to check (POSIX or Windows).

    Returns string

    The potentially changed path (POSIX).

createSubdomainRegexp

  • createSubdomainRegexp(baseUrl: string): RegExp
  • Creates a regular expression that matches URLs containing the given baseUrl, or a subdomain of the given baseUrl. In case there is a subdomain, the first match of the regular expression will be that subdomain.

    Examples with baseUrl http://test.com/foo/:

    • Will match http://test.com/foo/
    • Will match http://test.com/foo/bar/baz
    • Will match http://alice.bob.test.com/foo/bar/baz, first match result will be alice.bob
    • Will not match http://test.com/
    • Will not match http://alicetest.com/foo/

    Parameters

    • baseUrl: string

      Base URL for the regular expression.

    Returns RegExp

decodeUriPathComponents

  • decodeUriPathComponents(path: string): string

encodeUriPathComponents

  • encodeUriPathComponents(path: string): string
  • Encodes all (non-slash) special characters in a URI path.

    Parameters

    • path: string

    Returns string

ensureTrailingSlash

  • ensureTrailingSlash(path: string): string
  • Makes sure the input path has exactly 1 slash at the end. Multiple slashes will get merged into one. If there is no slash it will be added.

    Parameters

    • path: string

      Path to check.

    Returns string

    The potentially changed path.

extractScheme

  • extractScheme(url: string): { rest: string; scheme: string }
  • Splits a URL (or similar) string into a part containing its scheme and one containing the rest. E.g., http://test.com/ results in { scheme: 'http://', rest: 'test.com/' }.

    Parameters

    • url: string

      String to parse.

    Returns { rest: string; scheme: string }

    • rest: string
    • scheme: string

getExtension

  • getExtension(path: string): string
  • Extracts the extension (without dot) from a path. Custom function since path.extname does not work on all cases (e.g. ".acl")

    Parameters

    • path: string

      Input path to parse.

    Returns string

isContainerIdentifier

isContainerPath

  • isContainerPath(path: string): boolean
  • Checks if the path corresponds to a container path (ending in a /).

    Parameters

    • path: string

      Path to check.

    Returns boolean

joinFilePath

  • joinFilePath(basePath: string, ...paths: string[]): string
  • Adds the paths to the base path.

    Parameters

    • basePath: string

      The base path (POSIX or Windows).

    • Rest ...paths: string[]

      Subpaths to attach (POSIX).

    Returns string

    The potentially changed path (POSIX).

normalizeFilePath

  • normalizeFilePath(path: string): string
  • Resolves relative segments in the path.

    Parameters

    • path: string

      Path to check (POSIX or Windows).

    Returns string

    The potentially changed path (POSIX).

toCanonicalUriPath

  • toCanonicalUriPath(path: string): string
  • Converts a URI path to the canonical version by splitting on slashes, decoding any percent-based encodings, and then encoding any special characters.

    Parameters

    • path: string

    Returns string

trimTrailingSlashes

  • trimTrailingSlashes(path: string): string
  • Makes sure the input path has no slashes at the end.

    Parameters

    • path: string

      Path to check.

    Returns string

    The potentially changed path.