According to the spec for the `URL.hash` setter in https://url.spec.whatwg.org/#urlutils-members , assigning an empty string to a URL's hash should remove the fragment identifier. In WebKit however it sets it to an empty string. The result is that the following will produce a 'http://example.com/' in Chrome/Firefox but 'http://example.com/#' in Safari. var url = new URL('http://example.com'); url.hash = ''; console.log(url.toString());
<rdar://problem/26863430>
Created attachment 281569 [details] Patch
Comment on attachment 281569 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=281569&action=review > Source/WebCore/html/URLUtils.h:287 > + String newFragment = value[0U] == '#' ? value.substring(1) : value; Would be better if some day setFragmentIdentifier was changed to take a StringView, then we would not have to allocate a new string just to contain a substring of what we were passed.
Comment on attachment 281569 [details] Patch Clearing flags on attachment: 281569 Committed r202176: <http://trac.webkit.org/changeset/202176>
All reviewed patches have been landed. Closing bug.
@Robert Knight: You should be able to test/verify the fix using tomorrow's nightly build at https://webkit.org/nightly/
Wow! That's a fast turn around. Thank-you both!