Skip to content
This repository

Object.toQueryString() and Element.toQueryString() #2356

piotr-cz opened this Issue April 30, 2012 · 4 comments

4 participants

Piotr Olmo Maldonado Dimitar Christoff Arian Stolwijk

Object.toQueryString() doesn't encode keys, while Element.toQueryString() does.


So I guess in Object.toQueryString

default: result = key + '=' + encodeURIComponent(value);
should just be
default: result = encodeURIComponent(key) + '=' + encodeURIComponent(value);

Dimitar Christoff

what is your use case? prototypejs don't encode keys either -


The thing is that one function does encode keys, while another doesn't. Check jsFiddle output:

element => queryString

> params%5Blanguage%5D=en-GB&params%5Btimezone%5D=1

element => object => queryString

Object.toQueryString( $form.toQueryString().parseQueryString() )
> params[language]=en-GB&params[timezone]=1
Arian Stolwijk

what do others do?

for example nodejs simply does this: querystring.stringify({a: 1, b: {c: 2}}); => 'a=1&b=', so it's probably a bit server specific.. are there any other good examples?

Also isn't e4e637a / related?

Olmo Maldonado

Assuming fixed. Reopen if still an issue.

Olmo Maldonado ibolmo closed this March 03, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.