Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a8dab21

Browse filesBrowse files
darkrishabhcodebytere
authored andcommitted
doc,url: fix url.hostname example
PR-URL: #33735 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 76b1863 commit a8dab21
Copy full SHA for a8dab21

File tree

Expand file treeCollapse file tree

1 file changed

+6
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-0
lines changed
Open diff view settings
Collapse file

‎doc/api/url.md‎

Copy file name to clipboardExpand all lines: doc/api/url.md
+6Lines changed: 6 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.