Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed handle of arrays in Object.toQueryString. #2744

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jarkt
Copy link

@jarkt jarkt commented Oct 13, 2015

Object.toQueryString({
  "a": [1, 2],
  "b": {"": [3, 4], "x": "y"},
  "c": null,
  "d": "e"
})

Old result: a[0]=1&a[1]=2&b[][0]=3&b[][1]=4&b[x]=y&d=e
New result: a=1&a=2&b[]=3&b[]=4&b[x]=y&d=e

Object.toQueryString({
  "a": [1, 2],
  "b": {"": [3, 4], "x": "y"},
  "c": null,
  "d": "e"
})

Old result: a[0]=1&a[1]=2&b[][0]=3&b[][1]=4&b[x]=y&d=e
New result: a=1&a=2&b[]=3&b[]=4&b[x]=y&d=e
@SergioCrisostomo
Copy link
Member

@jarkt thank you for the fix suggestion!

There are specs failing with this code suggestion. Which means a BC (breaking change).

Which issue is this fixing? Is this related with URI issues in More?

@jarkt
Copy link
Author

jarkt commented Oct 13, 2015

Yes exactly. The function shouldn’t automatically number parameters with the same name. I think the specs are wrong.

Object.toQueryString("a[]=1&a[]=2".parseQueryString())

This should return only the input string, but instead mootools adds one more dimension and returns "a[][0]=1&a[][1]=2".
parseQueryString and toQueryString actually don’t work fine together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants