Re: [whatwg/url] Setters can cause failure to roundtrip (#651)

A few options here:

1. Concede that setters may make URLs non-roundtrippable, and be okay with that.
2. In a setter, if the particular component is completely removed, check if the serialization ends with a space, and trim the path if needed.
3. Don't allow trailing spaces in cannot-be-a-base URL paths in the initial parse, so parsing `data:text/html,hello #hash` would result in `data:text/html,hello#hash`.

Option 1 is probably the most web-compatible for the most content, but leaves a weird edge case and a sour taste in my mouth. Option 2 can be a bit surprising to the user (the pathname can change even when only hash is being set), but probably also web-compatible too. Option 3 is the most theoretically pleasing, but I would not be surprised if some web content depends on `data:text/html,hello ? world` being rendered as `hello ? world`. (After the change, it would be rendered instead as `hello? world`.)

I'm leaning towards option 2.

-- 
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/651#issuecomment-926974472

Received on Friday, 24 September 2021 23:57:26 UTC