I suspect this is going to cause a few gasps ;-) but if order is
unpredictable for queryString's alternate form why support it? At some
point, that's just going to cause surprise and result in x-browser
problems?
Also, it looks like (i.e. I have not tried it) queryString discards
anything where the value is missing. Query parameters with no value are
legitimate and really should be allowed. Hmm, the same is true when
parsing query strings so it looks like parseQueryString may be
incorrect too.
Cheers, Matt
Personally, I would say parseQueryString's useArrays should default to
true - that's how URLs work - and to explicitly turn it off.
I would also prefer to get a list of (name,value) pairs back, i.e. in
the correct order. It shouldn't be difficult to go from that to a
dict-like object if that's a more convenient representation for the
task.
Cheers, Matt
Agreed but I don't like "in most cases" much. But anyway, this is an
alternative form so I, too, can use it when it makes things easier and
I know the server won't care.
Perhaps there is really a need for a URL class of some sort so that
things can be both correct and easy? Nevow has this (although it's not
perfect) and it's a great thing.
>
> > Also, it looks like (i.e. I have not tried it) queryString discards
> > anything where the value is missing. Query parameters with no value are
> > legitimate and really should be allowed. Hmm, the same is true when
> > parsing query strings so it looks like parseQueryString may be
> > incorrect too.
>
> You *should* be able to give a value of '' to have an empty value
> appear in the query string. In the case of null values, there is a
> choice between three possible actions:
>
> 1) drop the parameter
> 2) use empty string
> 3) use the word "null"
4) just add the name to the query string with no '=' or value
i.e. (using the alternate queryString form ;-)) ...
queryString({foo:null, bar: 'wibble'})
gives:
foo&bar=wibble