[whatwg/webidl] Consider adding a URLString type (Issue #1454)

### What problem are you trying to solve?

While investigating https://github.com/w3ctag/design-principles/issues/303, @ylafon and I wanted to search for all the WebIDL attributes that take URLs across the platform. This is difficult because [URL parameters are passed as `USVString`](https://w3ctag.github.io/design-principles/#idl-string-types) (or sometimes `DOMString`), which of course is also used for many other purposes.

### What solutions exist today?

_No response_

### How would you solve it?

I see two alternatives:
1. Add `typedef USVString URLString;` in https://webidl.spec.whatwg.org/#common, and encourage fields that want URLs to take that type alias as slightly better documentation. The documentation improvement is fairly small for fields that are already named `url` or `fooURL`.
2. Add a new URLString primitive type that auto-converts between strings and [URL records](https://url.spec.whatwg.org/#concept-url). This could simplify some spec prose that currently has to do the conversion itself.

I don't have a strong opinion on the naming bikeshed.

### Anything else?

_No response_

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/issues/1454
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/webidl/issues/1454@github.com>

Received on Wednesday, 4 December 2024 11:12:49 UTC