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

@annevk :
> So I was wondering how that would work in Node or Deno.

The answer is, it wouldn't, not without additional context.

For those advocating for more support of relative URLs here, the challenges are that:

(a) it's impossible to interpret a relative URL reliably without at least a scheme because the semantic interpretation and normalization of the relative parts could change from one scheme to the next.
(b) the relative URL simply isn't usable by itself. In order to make use of it at all you need to know what it's *relative to*. In the browser, there's always the context of whatever page you're currently looking at. This gives the *illusion* that relative URLs like `<a href="./foo">thing</a>` are useful because that outer context is abstracted away. That context simply does not exist in Node.js but it's no less critical.

@sholladay makes the statement, "I want to be able to parse and resolve relative URLs in an environment-agnostic way" ... but that's *impossible* because you cannot separate the environment from either the parsing or the resolving! Sure, you could transform one relative URL fragment into another relative URL fragment, but neither are actually *usable* without the environment and context.

The way to move forward, here, I think, is for those advocating for a change here to provide clear answers to:

1. How are you intending to *use* the relative URLs?
2. Is a change to the `URL` API actually necessary, or is a secondary API workable? e.g. `const fragment1 = new URLFragment('/foo/'); const fragment3 = new URLFragment('bar', fragment1)`. The difference here is that `URLFragment` could never be interpreted as a usable `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/531#issuecomment-837029855

Received on Monday, 10 May 2021 17:43:23 UTC