- From: Karl <notifications@github.com>
- Date: Tue, 26 Oct 2021 20:50:53 -0700
- To: whatwg/url <url@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/url/issues/668@github.com>
The recent change which renamed "cannot-be-a-base" URLs to "URLs with opaque paths" reflects the reality that you _can_ parse some relative references against them (e.g. fragment-only relative references). However, it also exposes that the parser is overly-restrictive: namely, that while you can use the API to _set_ a query on a URL with an opaque path, you can't parse a relative reference which includes a query against them. Trying this out against the JSDOM implementation: ```js var url = new whatwgURL.URL("opq:hello"); console.log("Before - " + url.toString()); try { var relative = new whatwgURL.URL("?q=foo", url); console.log("Worked! - " + relative.toString()); } catch(ex) { console.log("Error - " + ex); } url.search = "?q=foo"; console.log("After - " + url.toString()); ``` Outputs the following: ``` [Log] Before - opq:hello [Log] Error - TypeError: Invalid URL: ?q=foo [Log] After - opq:hello?q=foo ``` I can't think of a reason why we would allow one way of writing this operation but not the other. This bug is to ask whether there would be any objections to changing the parser to accept queries in relative references when the baseURL has an opaque path. If there aren't, I'd be happy to draft a PR and add some tests. -- 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/668
Received on Wednesday, 27 October 2021 03:51:06 UTC