rendrjs / rendr

Render your Backbone.js apps on the client and the server, using Node.js.
MIT License
4.09k stars 312 forks source link

Array parameters changed from `foo[]=1&foo[]=2` to `foo=1&foo=2` #416

Closed wvengen closed 9 years ago

wvengen commented 9 years ago

After a recent update of master, I find that array parameters are passed through differently (see title). This broke querying with array parameters for my Rails-based API.

I suspect that 33ba3149bbe0e112a764213ef9aa9b969af4da82 is the culprit, with url.format using querystring to create the query string, instead of passing through the path as composed by qs (I guess here).

saponifi3d commented 9 years ago

thanks for reporting this! can you give some quick example code of how you were running into this issue? (is it in a controller or?)

wvengen commented 9 years ago

I guess this would help - #423

saponifi3d commented 9 years ago

Good news, bad news on this.. i can pretty easily get it to output ?q[0]=1&q[1]=3 but not ?q[]=1&q[]=3 - and i'm pretty sure things like rails doesn't like the index to be there. The reason why it currently outputs ?q=1&q=3 is

qs is setup to be able to parse either option, but i think it only ever outputs with index. Would having the index in the array be a deal breaker for you? I'm having problems finding anything in node that formats it with []'s... but they can all read it with them.

wvengen commented 9 years ago

Thanks for looking into this!

I've tested Ruby on Rails 4.1.6 and that doesn't accept arrays indexed with numbers :( And I'm probably not the only one using Rails. I see a couple of options:

wvengen commented 9 years ago

It seems this has the attention of upstream :) See https://github.com/hapijs/qs/issues/46 and https://github.com/hapijs/qs/pull/65

saponifi3d commented 9 years ago

thanks for all the info on this! just opened up a PR for it.

wvengen commented 9 years ago

Thank you, it works! And I guess after arrayFormat has been implemented, we might be able to use qs again.