Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "index"

Index

Type aliases

UrlLike

UrlLike: URL | string

A URL instance or valid absolute URL string.

Variables

Const WINDOWS_PREFIX_REGEX

WINDOWS_PREFIX_REGEX: RegExp = /^[\\/]{2,}([^\\/]+)(?:$|[\\/]+)/

Const WINDOWS_UNC_REGEX

WINDOWS_UNC_REGEX: RegExp = /^unc(?:$|[\\/]+)([^\\/]+)(?:$|[\\/]+)/i

Functions

asFuri

  • Normalizes the input to a Furi instance.

    Parameters

    • input: UrlLike

      URL string or instance to normalize.

    Returns Furi

    Furi instance. It is always a new instance.

asWritableUrl

  • asWritableUrl(input: UrlLike): URL
  • Normalizes the input to a writable URL instance.

    Parameters

    • input: UrlLike

      URL string or instance to normalize.

    Returns URL

basename

  • basename(furi: UrlLike, ext?: undefined | string): string
  • Returns the basename of the file URI.

    This function is similar to Node's require("path").basename.

    Parameters

    • furi: UrlLike

      Absolute file:// URI.

    • Optional ext: undefined | string

      Extension (will be removed if present).

    Returns string

    URI-encoded basename.

formatFileUrl

  • formatFileUrl(pathname: string): URL
  • Creates a frozen file:// URL using the supplied pathname.

    internal

    Parameters

    • pathname: string

      Pathname for the URL object.

    Returns URL

    Frozen file:// URL object.

fromPosixPath

  • fromPosixPath(absPath: string): URL
  • Converts an absolute Posix path to a frozen URL object.

    Example:

    fromPosixPath("/dir/foo");
    // -> new URL(file:///dir/foo");

    Parameters

    • absPath: string

      Absolute Posix path to convert

    Returns URL

    Frozen file:// URL object.

fromSysPath

  • fromSysPath(absPath: string): URL
  • Converts an absolute system-dependent path to a frozen URL object.

    Use fromPosixPath or fromWindowsPath if you want system-independent results.

    Example:

    // On a Windows system:
    fromSysPath("C:\\dir\\foo");
    // -> new URL("file:///C:/dir/foo");
    
    // On a Posix system:
    fromSysPath("/dir/foo");
    // -> new URL("file:///dir/foo");

    Parameters

    • absPath: string

      Absolute system-dependent path to convert

    Returns URL

    Frozen file:// URL object.

fromWindowsPath

  • fromWindowsPath(absPath: string): URL
  • Converts an absolute Windows path to a frozen URL object.

    Example:

    fromWindowsPath("C:\\dir\\foo");
    // -> new URL(file:///C:/dir/foo");
    fromWindowsPath("\\\\?\\unc\\server\\Users\\foo");
    // -> new URL("file://server/Users/foo");

    Parameters

    • absPath: string

      Absolute Windows path to convert

    Returns URL

    Frozen file:// URL object.

join

  • join(base: UrlLike, ...paths: keyof (string | ReadonlyArray<string>)[]): Furi
  • Appends the provided components to the pathname of base.

    It does not mutate the inputs. If component list is non-empty, the hash and search are set to the empty string.

    Parameters

    • base: UrlLike

      Base URL.

    • Rest ...paths: keyof (string | ReadonlyArray<string>)[]

      Paths to append. A path is either a string representing a relative or absolute file URI, or an array of components. When passing an array of components, each component will be URI-encoded before being appended.

    Returns Furi

    Joined URL.

parent

  • Returns the parent URL.

    If input is the root, it returns itself (saturation). If input has a trailing separator, it is first removed.

    Parameters

    Returns URL

    Parent URL.

relative

  • Computes the relative or absolute file:// URI from from to to.

    The result is an absolute URI only if the arguments have different hosts (for example when computing a URI between different Windows networked drives).

    If both URIs are equivalent, returns "".

    Otherwise, returns a relative URI starting with "./" or `"../".

    Parameters

    Returns string

    Relative (or absolute) URI between the two arguments.

toBackwardSlashes

  • toBackwardSlashes(str: string): string
  • Replaces all the forward slashes by backward slashes.

    internal

    Parameters

    • str: string

      Input string.

    Returns string

toForwardSlashes

  • toForwardSlashes(str: string): string
  • Replaces all the backward slashes by forward slashes.

    internal

    Parameters

    • str: string

      Input string.

    Returns string

toPosixPath

  • toPosixPath(furi: UrlLike): string
  • Converts a File URI to a Posix path.

    Requires the host to be either an empty string or "localhost".

    Example:

    toPosixPath("file:///dir/foo");
    // -> "/dir/foo";

    Parameters

    • furi: UrlLike

      File URI to convert.

    Returns string

    Posix path.

toSysPath

  • toSysPath(furi: UrlLike, windowsLongPath?: boolean): string
  • Converts a File URI to a system-dependent path.

    Use toPosixPath, toWindowsShortPath or toWindowsLongPath if you want system-independent results.

    Example:

    // On a Windows system:
    toSysPath("file:///C:/dir/foo");
    // -> "C:\\dir\\foo";
    toSysPath("file:///C:/dir/foo", true);
    // -> "\\\\?\\C:\\dir\\foo";
    
    // On a Posix system:
    toSysPath("file:///dir/foo");
    // -> "/dir/foo";

    Parameters

    • furi: UrlLike

      File URI to convert.

    • Default value windowsLongPath: boolean = false

      Use long paths on Windows. (default: false)

    Returns string

    System-dependent path.

toWindowsLongPath

  • toWindowsLongPath(furi: UrlLike): string
  • Converts a File URI to a Windows long path.

    The result is either a long device path or a long UNC server path.

    Example:

    toWindowsPath("file:///C:/dir/foo");
    // -> "\\\\?\\C:\\dir\\foo";
    toWindowsPath("file://server/Users/foo");
    // -> "\\\\?\\unc\\server\\Users\\foo";

    Parameters

    • furi: UrlLike

      File URI to convert.

    Returns string

    Windows long path.

toWindowsShortPath

  • toWindowsShortPath(furi: UrlLike): string
  • Converts a File URI to a Windows short path.

    The result is either a short device path or a short UNC server path.

    Example:

    toSysPath("file:///C:/dir/foo");
    // -> "C:\\dir\\foo";
    toSysPath("file://server/Users/foo");
    // -> "\\\\server\\Users\\foo";

    Parameters

    • furi: UrlLike

      File URI to convert.

    Returns string

    Windows short path.

Generated using TypeDoc