- From: Tab Atkins Jr. <jackalmage@gmail.com>
- Date: Sat, 13 Oct 2012 14:14:16 -0700
- To: Mike Dierken <mike@dierken.com>
- Cc: WHATWG <whatwg@whatwg.org>, Glenn Maynard <glenn@zewt.org>
On Sat, Oct 13, 2012 at 1:39 PM, Mike Dierken <mike@dierken.com> wrote: > Since a URL query string is not a strict map with only one value for a > key, would the get/set operations allow for an array as well as an > atomic value? Yes. Regardless of the getters vs get() discussion, I think there was consensus on the *operation* of the get/set operations. For the sake of this discussion, I'll assume we use the Map api. When you call get(), you'll get a *single* value - the first of the potentially multiple values - or null. When you call getAll(), you'll get a (possibly empty) array of values. When you call set(), if you pass an array it sets all the values, otherwise it stringifies the value and sets it as the sole value for that key. In other words, given an initial query of "?a=1&a=2", you get the following results: query.get('a') => 1 query.get('b') => null query.getAll('a') => [1,2] query.getAll('b') => [] query.set('a',3) => "?a=3" query.set('b', [4,5]) => "?a=3&b=4&b=5" query.set('c', {'c':1}) => "?a=3&b=4&b=5&c=%5Bobject%20Object%5D" ~TJ
Received on Saturday, 13 October 2012 21:15:04 UTC