Re: [whatwg/url] Support relative URLs (#531)

Hi, I’m in a similar situation. I’m prototyping a bundler and I keep running into issues using the WHATWG URL class, specifically because it does not parse origin-relative URLs. The use-case is that I want to specify a common prefix for the public distribution of static files; for instance, the prefix can be the string `"/static/"`, implying that the origin is the same origin as the server, but it can also be an absolute URL on a different origin (`"https://mycdn.com/"`). Some common operations I need include resolve relative and absolute URLs against this base, detecting if another URL is “outside” the base, and getting the relative path of a URL relative to the base, all of which could be done if an origin relative URL could be passed to the URL constructor, something like `new URL("main.js", "/static/")`.

If anyone has any solutions, I’d love to hear about it. I’m loathe to abandon the URL class completely because of all the work it does in parsing URLs, but right now I have a Frankenstein system with URLs, the path/posix module, and regexes that I’d like to abstract.

-- 
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/531#issuecomment-681507124

Received on Thursday, 27 August 2020 05:15:48 UTC