summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiran Tal <liran.tal@gmail.com>2020-04-11 17:02:59 +0300
committerRuben Bridgewater <ruben@bridgewater.de>2020-04-28 13:58:31 +0200
commitde3ab9f5764991282abb513bc02b19698bc725fe (patch)
treeba1e48a5326567add50fc0d4e8996e6479d81b06
parentbd40a8b3d7de1bb706152d2ae97c48cbb6dff20d (diff)
downloadnode-new-de3ab9f5764991282abb513bc02b19698bc725fe.tar.gz
doc: improve WHATWG url constructor code example
Currently, the URL docs for the WHATWG URL spec support are somewhat lacking in their code example of how to access the new URL constructor that lives inside the core url package. PR-URL: https://github.com/nodejs/node/pull/32782 Reviewed-By: Anna Henningsen <anna@addaleax.net>
-rw-r--r--doc/api/url.md7
1 files changed, 7 insertions, 0 deletions
diff --git a/doc/api/url.md b/doc/api/url.md
index 49f56509fe..6950c92f09 100644
--- a/doc/api/url.md
+++ b/doc/api/url.md
@@ -105,6 +105,13 @@ const myURL = new URL('/foo', 'https://example.org/');
// https://example.org/foo
```
+The URL constructor is accessible as a property on the global object.
+It can also be imported from the built-in url module:
+
+```js
+console.log(URL === require('url').URL); // Prints 'true'.
+```
+
A `TypeError` will be thrown if the `input` or `base` are not valid URLs. Note
that an effort will be made to coerce the given values into strings. For
instance: