Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow options to be passed to the qs module when using bodyParser.urlencoded({ extended: true }) #46

Closed
jcready opened this issue Sep 15, 2014 · 6 comments
Labels

Comments

@jcready
Copy link

jcready commented Sep 15, 2014

I have run into an issue with urlencoded sparse arrays and the way the qs module is handling them:

When creating arrays with specific indices, qs will compact a sparse array to only the existing values preserving their order.

Qs.parse('a[1]=b&a[15]=c');
// { a: ['b', 'c'] }

Ideally I would like to be able to pass options to the qs.parse() call so that I can override the arrayLimit option. I believe the syntax for doing this could look something like this:

bodyParser.urlencoded({
  extended: {
    arrayLimit: 0
  }
})

The extended option would still evaluate to "truthy" and would therefore use the qs module for parsing, but it would also allow developers to override the current hardset arrayLimit option passed to qs.parse() (along with any other qs specific options).

@jcready jcready changed the title Allow options to be passed to the qs module when using bodyParser.urlencoded(options) Allow options to be passed to the qs module when using bodyParser.urlencoded({ extended: true }) Sep 15, 2014
@dougwilson
Copy link
Contributor

The answer is no, because the reason the option is called extended: true and not parser: 'qs' is because you are not supposed to know it is using qs so we can switch it at any time. v2 of this module will actually default to the more-sane arrayLimit: 0, but you'll have to wait until then.

@dougwilson
Copy link
Contributor

Sorry, I'm in the mountains and lost cell before I could finish. I will have a solution for you tonight, in the form of v2. v2 will actually have the default you want, but it will also allow you to use any parser you want, so you can supply any options to qs or even use a different parser module. I hope that helps.

@jcready
Copy link
Author

jcready commented Sep 15, 2014

This is perfect! Thank you for the quick turn around. 🤘

@dougwilson
Copy link
Contributor

No problem! Though, I hate to say it, I did not get as much time tonight as I was hoping, so only part of the 2.0 release has been completed so far. I should have the rest completed sometime tomorrow :)

@dougwilson
Copy link
Contributor

Hi @jcready just posting an update here, don't want to leave you hanging :) I have been on vacation this week (can't you tell? ;) ), so it's just slow going since I'm just fitting this in to downtime, haha. The 2.0 release itself does have a little bit more than just this change, including a whole new module that allows people to use body parsing without express at all! I made some great progress yesterday, though :)

@jcready
Copy link
Author

jcready commented Sep 17, 2014

You take your time, sir! And enjoy that vacation. 😎

dougwilson added a commit that referenced this issue Oct 30, 2014
closes #42
closes #43
closes #46
closes #58
closes #60
closes #61
closes #65
dougwilson added a commit that referenced this issue Nov 22, 2014
closes #42
closes #43
closes #46
closes #58
closes #60
closes #61
closes #65
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants