[whatwg] [URL] DOM API Feedback
w3c at adambarth.com
Wed Nov 14 11:12:50 PST 2012
On Wed, Nov 14, 2012 at 10:54 AM, Anne van Kesteren <annevk at annevk.nl> wrote:
> On Thu, Nov 8, 2012 at 5:58 PM, Adam Barth <w3c at adambarth.com> wrote:
>> On Thu, Nov 8, 2012 at 6:22 AM, Alex Russell <slightlyoff at google.com> wrote:
>>> - "username" and "password" properties are missing
>>> - There aren't any provided comparison functions. I.e., there's no way
>>> to tell if two URL objects reference the same absolute URL, if
>>> one references a path in the same domain, etc.
>> The notion of "the same absolute URL" is a bit slippery. It depends
>> on how well you understand various URL components (e.g., octal
>> encodings of IP addesss). We could define something, of course, but
>> we'd just need to do so carefully.
> Yeah, it would be useful to have some use cases and examples here to
> work from. E.g. I suspect we may want to have a method at some point
> that considers these equal:
> even though they would always be considered strictly distinct
> currently (and some servers reportedly rely on this distinction).
>> Yes, the http://url.spec.whatwg.org/#urlquery interface lets you get
>> at parsed URL parameters. I don't think there's currently a way to
>> turn them into form data objects, but that would make sense.
>> We might also want to add a bulk setter that takes a Dictionary.
> Concrete suggestions for URLQuery are very much welcome. For behavior too.
> get()/getAll() are clear.
> set() not so much:
> what happens? Or with set("x", [1,2])? And set("x", [1,2,3]? Idea:
> So set() replaces values in order, removes parameters for which no
> values are set, and adds parameters if there are no existing
> I think that calls for add() as well, which simply appends a
> parameter, irrespective of what is there now.
Having multiple parameters with the same name seems like a bit of an
edge case to me. I wonder if we can get a better API by treating it
as an edge case? Here's a proposal:
add("foo", "bar") <--- Appends a parameter foo=bar to the existing
query string (even if there's already a parameter foo earlier.)
}) <--- Blows away the existing query string and replaces it with
In this approach, set() doesn't support having multiple parameters
with the same name. If you need that, you need to use add().
> Allowing new FormData(URLQuery) makes sense to me.
>> That's covered in step 1 of
>> <http://url.spec.whatwg.org/#constructors>. If there's no explicit
>> base, the URL is resolved relative to about:blank. To me, that seems
>> better that implicitly using the document's base URL. You can always
>> supply the document's base URL from document.baseURI if you want.
> Yeah, that was my thinking too.
More information about the whatwg