Skip to content

Commit a8dab21

Browse files
darkrishabhcodebytere
authored andcommitted
doc,url: fix url.hostname example
PR-URL: #33735 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent 76b1863 commit a8dab21

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

doc/api/url.md

+6
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,15 @@ const myURL = new URL('https://example.org:81/foo');
210210
console.log(myURL.hostname);
211211
// Prints example.org
212212

213+
// Setting the hostname does not change the port
213214
myURL.hostname = 'example.com:82';
214215
console.log(myURL.href);
215216
// Prints https://example.com:81/foo
217+
218+
// Use, myURL.host to change the hostname and port
219+
myURL.host = 'example.org:82';
220+
console.log(myURL.href);
221+
// Prints https://example.org:82/foo
216222
```
217223

218224
Invalid host name values assigned to the `hostname` property are ignored.

0 commit comments

Comments
 (0)