File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -210,9 +210,15 @@ const myURL = new URL('https://example.org:81/foo');
210210console .log (myURL .hostname );
211211// Prints example.org
212212
213+ // Setting the hostname does not change the port
213214myURL .hostname = ' example.com:82' ;
214215console .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
218224Invalid host name values assigned to the ` hostname ` property are ignored.
You can’t perform that action at this time.
0 commit comments