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 <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
  • Loading branch information
darkrishabh authored and BethGriggs committed Dec 9, 2020
1 parent 0f7e2c0 commit e55d0b9
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 e55d0b9

Please sign in to comment.