-
Notifications
You must be signed in to change notification settings - Fork 23.2k
Please doc unexpected behavior of the URL.host setter #37834
Description
MDN URL
https://developer.mozilla.org/en-US/docs/Web/API/URL/URL
What specific section or headline is this issue about?
The URL.host property.
What information was incorrect, unhelpful, or incomplete?
According to https://url.spec.whatwg.org/#dom-url-host,
If the given value for the host setter lacks a port, this’s URL’s port will not change. This can be unexpected as host getter does return a URL-port string so one might have assumed the setter to always "reset" both.
What did you expect to see?
I'd expect this to be documented on the host property.
This is a non-intuitive behavior, especially when setting host from a Host or X-Forwarded-Host header. Especially given that .hostname exists, which would seem to be the way to update the hostname without updating the port.
Do you have any supporting links, references, or citations?
Yep!
https://url.spec.whatwg.org/#dom-url-host
Do you have anything more you want to share?
Thanks for MDN! ❤️
I'd make the PR myself, but I started reading your CONTRIBUTING.md and it's a bit long/involved for me to take on for this small of a change, so hopefully someone who already has all of that loaded into their head can pick this up. 😊