Skip to content

Commit

Permalink
doc,url: fix url.hostname example
Browse files Browse the repository at this point in the history
PR-URL: #33735
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
darkrishabh authored and aduh95 committed Nov 18, 2020
1 parent d05c271 commit 665da27
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doc/api/url.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 665da27

Please sign in to comment.