Normalizes the input to a writable URL
instance.
URL string or instance to normalize.
Returns the basename of the file URI.
This function is similar to Node's require("path").basename
.
Absolute file://
URI.
Extension (will be removed if present).
URI-encoded basename.
Creates a frozen file://
URL using the supplied pathname
.
Pathname for the URL object.
Frozen file://
URL object.
Converts an absolute Posix path to a frozen URL object.
Example:
fromPosixPath("/dir/foo");
// -> new URL(file:///dir/foo");
Absolute Posix path to convert
Frozen file://
URL object.
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");
Absolute system-dependent path to convert
Frozen file://
URL object.
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");
Absolute Windows path to convert
Frozen file://
URL object.
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.
Base URL.
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.
Joined URL.
Returns the parent URL.
If input
is the root, it returns itself (saturation).
If input
has a trailing separator, it is first removed.
Input URL.
Parent URL.
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 `"../".
Relative (or absolute) URI between the two arguments.
Replaces all the forward slashes by backward slashes.
Input string.
Replaces all the backward slashes by forward slashes.
Input 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";
File URI to convert.
Posix path.
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";
File URI to convert.
Use long paths on Windows. (default: false
)
System-dependent path.
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";
File URI to convert.
Windows long path.
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";
File URI to convert.
Windows short path.
Generated using TypeDoc
A
URL
instance or valid absolute URL string.