Re: URLQuery / FormData

On Mon, Sep 9, 2013 at 9:59 PM, Jonas Sicking <jonas@sicking.cc> wrote:
> On Mon, Sep 9, 2013 at 1:30 PM, Anne van Kesteren <annevk@annevk.nl> wrote:
>> * get(name) -- always returns an array, with ES6 destructering this
>> should be fine
>
> This seems like optimizing for the rare case.

I agree with Jonas. The application code calling .get() will
ordinarily expect exactly 1 entry, right? And otherwise it usually
expects 0 or 1?

So, there's one specific thing applications will want to be able to
ask of this object, more than anything else. There should be a method
that expresses that.

What to do when .get() finds multiple values? It seems safest to
ignore the extras. Throwing an exception is another possibility, ever
so slightly less safe ISTM (because an attacker might be able to
trigger an exception at certain .get() call sites--not a very likely
attack vector, but still).

-j

Received on Monday, 9 September 2013 23:06:24 UTC