Skip to content

Fixed handle of arrays in Object.toQueryString. - #2744

Open
jarkt wants to merge 1 commit into
mootools:masterfrom
jarkt:master
Open

Fixed handle of arrays in Object.toQueryString.#2744
jarkt wants to merge 1 commit into
mootools:masterfrom
jarkt:master

Conversation

@jarkt

@jarkt jarkt commented Oct 13, 2015

Copy link
Copy Markdown
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
Copy Markdown
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

jarkt commented Oct 13, 2015

Copy link
Copy Markdown
Author

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