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

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

Comments

Projects
None yet
4 participants

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

see
http://jsfiddle.net/piotr_cz/y28zb/

So I guess in Object.toQueryString

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

Member

DimitarChristoff commented Jun 21, 2012

what is your use case? prototypejs don't encode keys either - https://github.com/sstephenson/prototype/blob/master/src/prototype/lang/hash.js#L289

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

element => queryString

$form.toQueryString()
> params%5Blanguage%5D=en-GB&params%5Btimezone%5D=1

element => object => queryString

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

arian commented Aug 8, 2012

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 / https://mootools.lighthouseapp.com/projects/2706/tickets/762 related?

Owner

ibolmo commented Mar 3, 2014

Assuming fixed. Reopen if still an issue.

@ibolmo ibolmo closed this Mar 3, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment