Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
piotr-cz opened this Issue · 4 comments

4 participants

@piotr-cz

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);

@DimitarChristoff
Collaborator

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

@piotr-cz

@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
@arian
Owner

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?

@ibolmo
Owner

Assuming fixed. Reopen if still an issue.

@ibolmo ibolmo closed this
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.