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

The `Request` object only "supports" relative URLs in environments like the browser that have a notion of an origin. Your suggestion does not work in environments such as Node.js, Deno, Bun, etc. 

It really needs to be recognized that `URL` *already* correctly handles relative URLs. The requirement, however, is that it is not possible to correctly parse a URL without *at least* knowing the protocol scheme to use. If you do not care about the authority part of the URL (the hostname, port, etc) then the correct way to handle relative URLs is to use a fake base URL as has been suggested.

```
const url = new URL('/foo/bar.json', 'https://nothing');
console.log(url.pathname);
```

No workarounds needed. Why is this not more than sufficient for this use case?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/531#issuecomment-2645821926
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/url/issues/531/2645821926@github.com>

Received on Saturday, 8 February 2025 16:27:48 UTC