[whatwg/url] Setting protocol should change port if default port matches (#327)

When setting port state, https://url.spec.whatwg.org/#port-state says:

> 3. Set url’s port to null, if port is url’s scheme’s default port, and to port otherwise

However now corresponding verbiage is included in the process for setting a url scheme scheme (a.k.a port).  This leads to inconsistent URL states, as illustrated in node.js's current implementation of this standard:

```
> u1 = new URL('https://foo.com:80')
URL {...}
> u2 = new URL('http://foo.com:443')
URL {...}
> u1.protocol = 'http:'
'http:'
> u2.port = 80
80
> String(u1)
'http://foo.com:80/'
> String(u2)
'http://foo.com/'
```

`u1` and `u2` both represent the same URL (scheme, host, port), but u1's port is set to 80, while u2's port is null.

The spec should dictate that when the scheme state is set, the port should be set to null if it matches the default port for that scheme.

-- 
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/327

Received on Monday, 26 June 2017 22:13:02 UTC