Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding a URLString type #1454

Open
jyasskin opened this issue Dec 4, 2024 · 3 comments
Open

Consider adding a URLString type #1454

jyasskin opened this issue Dec 4, 2024 · 3 comments
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest

Comments

@jyasskin
Copy link
Member

jyasskin commented Dec 4, 2024

What problem are you trying to solve?

While investigating w3ctag/design-principles#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 (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. 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

@jyasskin jyasskin added addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest labels Dec 4, 2024
@annevk
Copy link
Member

annevk commented Dec 4, 2024

I doubt most of these places can automatically convert to a URL record? I could be missing something, but I suspect more context is needed for that in most cases.

@jyasskin
Copy link
Member Author

jyasskin commented Dec 4, 2024

I should go look at the prose for several of these to make sure this is plausible (but I won't be able to during this week's TAG meeting), but if you're thinking about the need for a base URL, maybe https://html.spec.whatwg.org/multipage/webappapis.html#api-base-url is sufficient?

@annevk
Copy link
Member

annevk commented Dec 4, 2024

Maybe, but then https://url.spec.whatwg.org/#dom-url-href cannot use it. https://fetch.spec.whatwg.org/#dom-response-redirect maybe could, though that also raises the current vs relevant settings object question.

Another question is basic vs full parser, where redirect() doesn't really invoke the right one today I think.

I think you have convinced me that it would certainly be an interesting exercise to find all these endpoints to do some kind of review and assess the need for a more dedicated type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest
Development

No branches or pull requests

2 participants