Closed sjhewitt closed 9 years ago
main problem that I see is that I think there is no standard for multiple parameters with same name.. I've seen ?foo[]=bar&foo[]=baz
(PHP does it this way by default) and ?foo=bar&foo=baz
and ?foo=bar,baz
I don't see how it's a problem... This solves the problem of getting multivalued parameters from the querystring, not specifying the way the developer should name their parameters.
It is a PHP quirk that it requires you to use names that end in []
to specify an array. In the comma separated case, it is the developer that has chosen to encode their values as comma separated, and they should split it themselves.
The simplest case that i'm trying to solve is: given a form like this, that submits using get:
<form method="">
<input type="hidden" name="foo" value="bar">
<input type="hidden" name="foo" value="baz">
<input type="submit">
</form>
Use crossroads to parse the resulting querystring
btw, I've removed the version commit.
@sjhewitt I agree with you, this is good as is. no need to worry about other weird use cases.
Updated with the suggested changes
thanks!
I've been using this pull request version for a few days now. It was much needed and is most appreciated. So far I've had no issues in using it, works perfectly for the app I am using it with.
One question regarding one of the weird use cases with "[]" denoting the array-type of the parameter (here: used with Rails): how can I prevent the parameter name from being URL-encoded?
For example: ...¶m%255B%255D=1&... vs ...¶m[]=1&
This commit was written by Kamaruni, I'm just submitting it as a pull request to get it merged into master
fixes #90