- From: Timothy Gu <notifications@github.com>
- Date: Sat, 15 May 2021 21:08:09 -0700
- To: whatwg/url <url@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Sunday, 16 May 2021 04:08:22 UTC
The spec currently provides for the following: ```js u = new URL("http://example.net/path"); u.hostname = "example.com:8080"; console.assert(u.hostname === "example.com"); // FF & WK: "example.net" console.assert(u.port === ""); u = new URL("http://example.net:8080/path"); u.hostname = "example.com:"; console.assert(u.hostname === "example.com"); // FF & WK: "example.net" console.assert(u.port === "8080"); ``` (The test cases came from [WPT](https://github.com/web-platform-tests/wpt/blob/e75d075b7c27fb29e83ca9f5ab785995fd09736f/url/resources/setters_tests.json#L1155-L1176).) However, no one actually implements this. Firefox and Safari both reject the given hostname value if it contains a port part, and leave the hostname unchanged. Shall we align with Firefox and Safari? <details><summary>(OTOH, Chrome does something that makes no sense, so I'd like to exclude it from the discussion for now.)</summary> ```js u = new URL("http://example.net/path"); u.hostname = "example.com:8080"; console.log(u.hostname); // prints "" console.log(u.href); // prints "http://example.com:8080/path" ``` </details> -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/whatwg/url/issues/601
Received on Sunday, 16 May 2021 04:08:22 UTC