File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -251,15 +251,15 @@ const myURL = new URL('https://example.org:81/foo');
251
251
console .log (myURL .hostname );
252
252
// Prints example.org
253
253
254
- // Setting an invalid hostname is ignored:
255
- myURL .hostname = ' example.com:82 ' ;
254
+ // Setting the hostname does not change the port
255
+ myURL .hostname = ' example.com' ;
256
256
console .log (myURL .href );
257
- // Prints https://example.org :81/foo
257
+ // Prints https://example.com :81/foo
258
258
259
259
// Use myURL.host to change the hostname and port
260
- myURL .host = ' example.com :82' ;
260
+ myURL .host = ' example.org :82' ;
261
261
console .log (myURL .href );
262
- // Prints https://example.com :82/foo
262
+ // Prints https://example.org :82/foo
263
263
```
264
264
265
265
Invalid host name values assigned to the ` hostname ` property are ignored.
You can’t perform that action at this time.
0 commit comments