Usage
import * as mod from "node:url";
The node:url
module provides utilities for URL resolution and parsing. It can
be accessed using:
import url from 'node:url';
Browser-compatible URL
class, implemented by following the WHATWG URL
Standard. Examples of parsed URLs may be found in the Standard itself.
The URL
class is also available on the global object.
The URLSearchParams
API provides read and write access to the query of a URL
. The URLSearchParams
class can also be used standalone with one of the
four following constructors.
The URLSearchParams
class is also available on the global object.
Returns the Punycode ASCII serialization of the domain
. If domain
is an
invalid domain, the empty string is returned.
Returns the Unicode serialization of the domain
. If domain
is an invalid
domain, the empty string is returned.
This function ensures the correct decodings of percent-encoded characters as well as ensuring a cross-platform valid absolute path string.
The url.format()
method returns a formatted URL string derived from urlObject
.
This function ensures that path
is resolved absolutely, and that the URL
control characters are correctly encoded when converting into a File URL.
The url.resolve()
method resolves a target URL relative to a base URL in a
manner similar to that of a web browser resolving an anchor tag.
This utility function converts a URL object into an ordinary options object as
expected by the http.request()
and https.request()
APIs.