Re: [whatwg] New URL Standard

On 25/09/2012 01:07 , Glenn Maynard wrote:
> On Mon, Sep 24, 2012 at 12:30 PM, Tab Atkins Jr. <jackalmage@gmail.com>wrote:
>> I suggest just making it a map from String->[String].  You probably
>> want a little bit of magic - if the setter receives an array, replace
>> the current value with it; anything else, stringify then wrap in an
>> array and replace the current value.  The getter should return an
>> empty array for non-existing params.  You should be able to set .query
>> itself with an object, which empties out the map and then runs the
>> setter over all the items.  Bam, every single methods is now obsolete.
>
> When should this API guarantee that it round-trips URLs cleanly (aside from
> quoting differences)?  For example, maintaining order in "a=1&b=2&a=1", and
> representing things like "a=1&b" (no '=') and "a&&b" (no key at all).

And round-tripping using ; as the separator instead of &. I mention this 
because I've seen actual production code (more than once) that relied on 
this. I have no idea how common it is though. I'm guessing not too much, 
but probably some since it was in HTML 4.01:

     http://www.w3.org/TR/html401/appendix/notes.html#h-B.2.2

Of course another option is to just not parse that into key-value pairs 
in the first place.

> By the way, it would also be nice for the query part of this API to be
> usable in isolation.

+1

-- 
Robin Berjon - http://berjon.com/ - @robinberjon

Received on Tuesday, 25 September 2012 11:55:02 UTC