- From: azu <notifications@github.com>
- Date: Wed, 02 Sep 2020 09:42:54 -0700
- To: whatwg/url <url@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/url/issues/539@github.com>
What should be the result of `new URL("#")`?
Browsers return different results and It confuses me.
In my understanding is that `new URL("#")` should throw a validation error.
1. [scheme start state](https://url.spec.whatwg.org/#scheme-start-state)
1. [skip] If c is an ASCII alpha, append c, lowercased, to buffer, and set state to scheme state.
2. [match] Otherwise, if state override is not given, set state to no scheme state and decrease pointer by 1. → go to [no schema state](https://url.spec.whatwg.org/#no-scheme-state)
2. [no schema state](https://url.spec.whatwg.org/#no-scheme-state)
1. [match] If base is null, or base’s cannot-be-a-base-URL flag is set and c is not U+0023 (#), validation error, return failure. → throw validation error
```js
if ( base === null || (cannot-be-a-base-URL && c !== "#")){
throw validation error
}
```
state value
- `base` is `null` (initial value)
- cannot-be-a-base-URL flag is not set
- `c` is `#`
---
Test results:
- Firefox 80.0 → throw TypeError: URL constructor: # is not a valid URL.
- Chrome 85 → return `URL {href: "about:blank#", origin: "null", protocol: "about:", username: "", password: "", …}`
- Safari 13.1.2 → return `URL {href: "about:blank#", origin: "null", protocol: "about:", username: "", password: "", …}`
- [whatwg-url](https://github.com/jsdom/whatwg-url) → throw Error
I can not found this test in [wpt/url](https://github.com/web-platform-tests/wpt/tree/master/url).
--
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/539
Received on Wednesday, 2 September 2020 16:43:06 UTC