Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

String.parseQueryString does not parse arrays correctly. #1038

Open
tvanreenen opened this Issue · 2 comments

3 participants

@tvanreenen

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@boppy

Okay, second try on that one. ;-) After finding out I was doing stupid things with my first try on fixing that issue, I enhanced my try:

http://jsfiddle.net/boppy/szeVE/7/

It's simply replacing the "php-style" (&foo[]=bar&foo[]=baz) keys with javastyle (&foo=bar&foo=baz). Works fine. I added some tests because I first replaced ANY "[]"s in the string - causing strings like "&foo=bar[]baz" to be destroyed.

@swhiteman

Hey @boppy I know it's been years, but I was working on my own non-framework query string parser and decided to check it against Moo's by extending String. Mine doesn't do nested objects yet (that will probably be a flag, because I don't need to process such structures in my app) but in the most common case -- standalone values + turning repeated values into arrays -- it's at least 100% faster than String.parseQueryString in Chrome and IE 9+, up to 200% faster in Safari, up to 500% (!) faster in IE8 (that's still something we want, right?). In FF it's only a tiny bit faster than Moo, for whatever reason.

Anyway, thought you might want to take a look. I'm not looking to create a MooTools PR here and I understand this is not a task that is usually done 10,000 of times (although for one app I'm building now, a link checker, it actually is called repeatedly). Also still a WIP. But anyway you might find it interesting:

http://jsperf.com/query-string-parsing-rereplacer/3

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.