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
URLexposes as writable ACCESSORS on its prototype. - MODULE_
METHODS - SEARCH_
PARAMS_ METHODS - Method names dispatched through
search_params_call(forinstance_has_methodwiring instdlib::mod;@@iteratormakes[...params]/for..ofwork). - STATIC_
METHODS - Statics on the
URLCLASS — distinct fromMODULE_METHODS, which are the legacyrequire('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, anotherURLSearchParams, or empty.- instance_
call URLinstance methods (component reads are plain data properties).- is_
component - Whether
nameis aURLcomponent whose assignment must refresh the derived fields. - refresh
- Refresh a
URLafter one of its components was assigned. - reparse
- Re-parse
urlfrom thehrefjust assigned to it. - search_
params_ call URLSearchParamsinstance methods.- split_
host - Split the
hostjust assigned tourlinto thehostnameandportit actually carries. - static_
call URL.canParse(input[, base])/URL.parse(input[, base]).