[whatwg] New URL Standard

Glenn Maynard glenn at zewt.org
Tue Sep 25 19:36:02 PDT 2012


On Tue, Sep 25, 2012 at 9:27 PM, Boris Zbarsky <bzbarsky at mit.edu> wrote:

> On 9/25/12 10:13 PM, Glenn Maynard wrote:
>
>>     The obvious use case is constructing a URI with a given query by
>>     hand, right?
>>
>> If you already have the "a=1&b=2" string, you can just assign it to
>> .search and not use the prepared-query-parameters interface at all.
>>
>
> I was thinking more like you have the arrays ["a", "b"] (hardcoded) and
> [1, 2] (provided by user).
>

You usually don't care about the resulting order in that case, right?
You'd just say something like

assert(key_names.length == user_data.length); // ["a", "b"].length == [1,
2].length
for(var i = 0; i < user_data.length; ++i)
    url.query[key_names[i]] = ]user_data[i];

When do you care about being able to specifically create (or distinguish)
"a=1&b=2" vs. "b=2&a=1" (or, a bit trickier, "a=1&b=2&a=3")?

-- 
Glenn Maynard



More information about the whatwg mailing list