From a8dab217eb433f126c588677f1575b1a38bd937e Mon Sep 17 00:00:00 2001 From: Rishabh Mehan Date: Fri, 5 Jun 2020 01:23:22 -0700 Subject: [PATCH] doc,url: fix url.hostname example PR-URL: https://github.com/nodejs/node/pull/33735 Reviewed-By: Gireesh Punathil Reviewed-By: Antoine du Hamel --- doc/api/url.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/api/url.md b/doc/api/url.md index e3f1adba94fc86..832a88a9f75bac 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -210,9 +210,15 @@ const myURL = new URL('https://example.org:81/foo'); console.log(myURL.hostname); // Prints example.org +// Setting the hostname does not change the port myURL.hostname = 'example.com:82'; console.log(myURL.href); // Prints https://example.com:81/foo + +// Use, myURL.host to change the hostname and port +myURL.host = 'example.org:82'; +console.log(myURL.href); +// Prints https://example.org:82/foo ``` Invalid host name values assigned to the `hostname` property are ignored.