Re: [whatwg/url] API mechanism for reporting validity errors (Issue #811)

It would also reflect the last operation, wouldn't it? For instance, non-fatal validation errors can occur when an IPv4 address contains non-decimal parts - e.g. `https://0x7F.1`. What's interesting about this is that the parser reformats the IP address so that it _is_ valid - the above produces the URL `https://127.0.0.1`.

In other words, this property would not be idempotent.

```
const url = new URL('https://0x7F.1');
console.log(url.valid); // false

const url2 = new URL(url.href)
console.log(url2.valid); // true!
```

I think this would be extremely difficult for users to understand or use effectively.

This suggests that validity may not in fact be a property of the URL, but rather a property of the inputs used to create the URL. So C (including "strict" versions of property setters, etc) would be the best API, IMO.

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

Message ID: <whatwg/url/issues/811/1892351283@github.com>

Received on Monday, 15 January 2024 15:10:30 UTC