Function pathToFileURL

  • Convert a filesystem path to a file:// URL.

    Returns

    A URL with the file:// scheme.

    Example

    const url = Bun.pathToFileURL("/foo/bar.txt");
    console.log(url.href); // "file:///foo/bar.txt"

    Internally, this function uses WebKit's URL API to convert the path to a file:// URL.

    Parameters

    • path: string

      The path to convert.

    Returns URL

  • Convert a filesystem path to a file:// URL.

    Returns

    A URL with the file:// scheme.

    Example

    const url = Bun.pathToFileURL("/foo/bar.txt");
    console.log(url.href); // "file:///foo/bar.txt"

    Internally, this function uses WebKit's URL API to convert the path to a file:// URL.

    Parameters

    • path: string

      The path to convert.

    Returns URL

Generated using TypeDoc