[whatwg/url] Encode percent(%)s that are not part of a percent-encoded byte when parsing a URL (#170)

Test case:
```
console.log(new URL('/%n', document.baseURI).pathname); // -> /%n
```
This is surperising to me, because I expect that the URL constructor either fail or return a valid url; however, '/%n' is not a valid url. If you feed '/%n' to `decodeURI()`, it will throw a `URIError`.

The spec just say that a percent that is part of a percent-encoded byte is a ["syntax violation"](https://url.spec.whatwg.org/#concept-basic-url-parser), but does not require the parser to throw or to fix the syntax.

I suggest encode percent(%)s that are not part of a percent-encoded byte when parsing a URL, i.e. '/%n' becomes '/%25n' after parsing.


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

Received on Thursday, 8 December 2016 03:19:23 UTC