Skip to main content

Module url

Module url 

Source
Expand description

Node url module: the WHATWG URL class (global + require('url').URL) and the legacy url.parse. A URL instance stores its components as data properties (so u.hostname reads directly) plus a @@native = "URL" tag for toString. Assigning one of those components goes through refresh, which rewrites the DERIVED fields (href, host, origin) so the object cannot disagree with itself; the searchParams it carries holds an @@ownerUrl back-reference so its own mutations rewrite the query in the other direction.

They remain OWN properties of the instance, where node has them as accessors on URL.prototype — so Object.keys(url) lists twelve names here and none in node.

Constants§

COMPONENTS
Parsed URL components. The component names a URL exposes as writable ACCESSORS on its prototype.
MODULE_METHODS
SEARCH_PARAMS_METHODS
Method names dispatched through search_params_call (for instance_has_method wiring in stdlib::mod; @@iterator makes [...params] / for..of work).
STATIC_METHODS
Statics on the URL CLASS — distinct from MODULE_METHODS, which are the legacy require('url') functions.

Functions§

call
construct
new URL(input[, base]).
construct_search_params
new URLSearchParams([init]) — from a query string, an object, an iterable of [key, value] pairs, another URLSearchParams, or empty.
instance_call
URL instance methods (component reads are plain data properties).
is_component
Whether name is a URL component whose assignment must refresh the derived fields.
refresh
Refresh a URL after one of its components was assigned.
reparse
Re-parse url from the href just assigned to it.
search_params_call
URLSearchParams instance methods.
split_host
Split the host just assigned to url into the hostname and port it actually carries.
static_call
URL.canParse(input[, base]) / URL.parse(input[, base]).