[whatwg/url] Path setter allows cannot-be-a-base URL to be created without the flag (#581)

Testing this out using the JSDom implementation:

```
> var url = new whatwgURL.URL("foo:/hello/world?someQuery")

> url.href
"foo:/hello/world?someQuery"

> url.pathname = ""
> url.href
"foo:?someQuery"

> url.pathname = "test"
> url.href
"foo:/test?someQuery"

> var url = new whatwgURL.URL("foo:?someQuery")
> url.pathname = "test"
> url.href
"foo:?someQuery"
```

When setting `pathname` to the empty string, we create a cannot-be-a-base URL (`"foo:?someQuery"`), but it is not flagged as such because the parser won't set this flag after "path start" state, which is where the setter begins. Therefore we can continue to set the `pathname` to something else. But if we parse that same string again, the cannot-be-a-base flag is correctly set and the subsequent `pathname` setter has no effect.

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

Received on Sunday, 21 February 2021 20:44:59 UTC