defunctzombie / node-url

node.js core url module as a module
MIT License
375 stars 96 forks source link

arrays in query objects are not formatted #25

Open shishircc opened 7 years ago

shishircc commented 7 years ago

If query object has array, it will not be formatted query = { a:{b:[1,2]},c:1} will result in a=&c=1

mauvm commented 7 years ago

I have the same problem.

querystring@0.2.0 is used under the hood for formatting the query. See https://github.com/defunctzombie/node-url/blob/13a35bd35a2cdf3fbfa7ee9c6ed5b927a48d6821/url.js#L410.

Unfortunately the querystring package does not stringify objects: https://github.com/Gozala/querystring/blob/master/encode.js#L24

I was only using pathname and query, so qs (which supporst stringifying nested objects) will do for me.