diff options
Diffstat (limited to 'doc/api/url.md')
-rw-r--r-- | doc/api/url.md | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/doc/api/url.md b/doc/api/url.md index a74ca26e08..837e41e8ff 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -55,7 +55,7 @@ properties of a WHATWG `URL` object. Parsing the URL string using the WHATWG API: ```js -const URL = require('url').URL; +const { URL } = require('url'); const myURL = new URL('https://user:pass@sub.host.com:8080/p/a/t/h?query=string#hash'); ``` @@ -607,7 +607,7 @@ Alias for [`urlSearchParams[@@iterator]()`][`urlSearchParams@@iterator()`]. Iterates over each name-value pair in the query and invokes the given function. ```js -const URL = require('url').URL; +const { URL } = require('url'); const myURL = new URL('https://example.org/?a=b&c=d'); myURL.searchParams.forEach((value, name, searchParams) => { console.log(name, value, myURL.searchParams === searchParams); @@ -1098,7 +1098,7 @@ using the [Punycode][] algorithm. Note, however, that a hostname *may* contain *both* Punycode encoded and percent-encoded characters. For example: ```js -const URL = require('url').URL; +const { URL } = require('url'); const myURL = new URL('https://%CF%80.com/foo'); console.log(myURL.href); // Prints https://xn--1xa.com/foo |