From b7f223ee044c470077e844a08c388e17c466467b Mon Sep 17 00:00:00 2001 From: Liran Tal Date: Sat, 11 Apr 2020 17:02:59 +0300 Subject: [PATCH 1/3] doc: improve WHATWG url constructor code example ## Why this PR ? 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. ## Suggested change Improve the code example that shows how the new URL constructor should be accessed to begin with. --- doc/api/url.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/api/url.md b/doc/api/url.md index 49f56509fe41e9..5b896ed2d91b8e 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -53,6 +53,7 @@ WHATWG URL's `origin` property includes `protocol` and `host`, but not Parsing the URL string using the WHATWG API: ```js +const URL = require('url').URL const myURL = new URL('https://user:pass@sub.example.com:8080/p/a/t/h?query=string#hash'); ``` From df1e5b942c3477946bf68b2ff1a17a876816f606 Mon Sep 17 00:00:00 2001 From: Liran Tal Date: Mon, 20 Apr 2020 16:37:40 +0300 Subject: [PATCH 2/3] chore: update url constructor example --- doc/api/url.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/api/url.md b/doc/api/url.md index 5b896ed2d91b8e..e4208e46542ec5 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -53,7 +53,6 @@ WHATWG URL's `origin` property includes `protocol` and `host`, but not Parsing the URL string using the WHATWG API: ```js -const URL = require('url').URL const myURL = new URL('https://user:pass@sub.example.com:8080/p/a/t/h?query=string#hash'); ``` @@ -106,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: + +``` +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: From 6d5f39301c707d93f40fa5bd0088346ede68e4c8 Mon Sep 17 00:00:00 2001 From: Liran Tal Date: Sat, 25 Apr 2020 11:42:32 +0300 Subject: [PATCH 3/3] fix: missing lang-code for markdown --- doc/api/url.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/url.md b/doc/api/url.md index e4208e46542ec5..6950c92f0980c8 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -108,7 +108,7 @@ const myURL = new URL('/foo', 'https://example.org/'); 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'. ```