Skip to content

Path setter allows cannot-be-a-base URL to be created without the flag #581

@karwa

Description

@karwa

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions