const {hostname, port} = location; const pathname = 'websocket'; const protocol = 'wss:' const target = {hostname, pathname, port, protocol, search: ''}; Object.assign(new URL(location), target); as a result of merging the above code, 0 value gets to the port URL { hash: "" host: "bugs.webkit.org:0" hostname: "bugs.webkit.org" href: "wss://bugs.webkit.org:0/websocket" origin: "wss://bugs.webkit.org:0" password: "" pathname: "/websocket" port: "0" protocol: "wss:" search: "" searchParams: URLSearchParams {append: function, delete: function, get: function, getAll: function, has: function, …} username: "" }
<rdar://problem/57444249>
Created attachment 384223 [details] Patch
Created attachment 384230 [details] Patch
Comment on attachment 384230 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=384230&action=review > Source/WebCore/html/URLUtils.h:236 > + unsigned port = value.toUInt(&success); Not related to this change, but it's a bit odd we use toUInt() here, rather than toUIntStrict(), since the former allows trailing garbage. Probably worth testing, but not in this change. (I also kind of want to change the toNumber functions to return Optionals).
Chromium allows trailing garbage, Firefox does not, the spec is a little unclear and seems to me that it would allow url.port="123?query" to override the path and query, but no browser allows that. I'm going to commit this as-is right now to save the toUIntStrict discussion for another day, because it doesn't seem to be causing compatibility problems in practice now.
Comment on attachment 384230 [details] Patch Clearing flags on attachment: 384230 Committed r252998: <https://trac.webkit.org/changeset/252998>
All reviewed patches have been landed. Closing bug.