2 ms·
So there are a few steps here. First parser.href = url; causes the URL to be parsed. When URLs are parsed, the spec [1] says: 2. If buffer is equal to ur
by jgraham 13y ago
So there are a few steps here. First
parser.href = url;
causes the URL to be parsed. When URLs are parsed, the spec [1] says:
2. If buffer is equal to url's scheme's default port, set buffer to the empty string.
3. Set url's port to buffer.
Then the host is serialized. Here the spec says:
2. If port is the empty string, return host, serialized.
Since is is the empty string in the case where the port is the default port, no port should be appended on output, even if there was one there on input (serializing host doesn't magically append a port).
I'm not really clear why this normalise function is needed at all though? Origin should be string comparable?
[1] http://url.spec.whatwg.org/#port-state http://url.spec.whatwg.org/#port-state
[2] http://url.spec.whatwg.org/#dom-url-host http://url.spec.whatwg.org/#dom-url-host