W3C home > Mailing lists > Public > whatwg@whatwg.org > November 2012

Re: [whatwg] [URL] DOM API Feedback

From: Adam Barth <w3c@adambarth.com>
Date: Wed, 14 Nov 2012 11:12:50 -0800
Message-ID: <CAJE5ia_Hoi_uumhjbx75d-0XptKSwuKgkNfF-vioXAP5HJyAdQ@mail.gmail.com>
To: Anne van Kesteren <annevk@annevk.nl>
Cc: whatwg <whatwg@whatwg.org>, Alex Russell <slightlyoff@google.com>
On Wed, Nov 14, 2012 at 10:54 AM, Anne van Kesteren <annevk@annevk.nl> wrote:
> On Thu, Nov 8, 2012 at 5:58 PM, Adam Barth <w3c@adambarth.com> wrote:
>> On Thu, Nov 8, 2012 at 6:22 AM, Alex Russell <slightlyoff@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:
> http://x/?test&test2
> http://x/?test2&test
> 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:
>   "?x&y&x=5&y"
>   set("x","1")
> what happens? Or with set("x", [1,2])? And set("x", [1,2,3]? Idea:
>   "?x=1&y&y"
>   "?x=1&y&x=2&y"
>   "?x=1&y&x=2&y&x3"
> So set() replaces values in order, removes parameters for which no
> values are set, and adds parameters if there are no existing
> parameters.
> 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.)
  "foo": "bar",
  "qux": "baz"
}) <--- 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.
> --
> http://annevankesteren.nl/
Received on Wednesday, 14 November 2012 19:57:36 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:17 UTC