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

bodyParser.urlencoded middleware adds empty object to req.body even if type is not met #366

Closed
skleeschulte opened this issue Jul 27, 2019 · 1 comment

Comments

@skleeschulte
Copy link

From the docs of bodyParser.urlencoded:

The type option is used to determine what media type the middleware will parse. [...] Defaults to application/x-www-form-urlencoded.

So I expected bodyParser.urlencoded to do nothing if Content-Type is not application/x-www-form-urlencoded. But bodyParser.urlencoded still adds an empty object to req.body, even if the type is not met. This way it gets unnecessarily hard to use multiple body parser for different types and check for an empty body.

Seeing that changing this behaviour might break existing apps, I'd suggest to add an option to configure this behaviour and maybe change the default in the future. What do you think?

@dougwilson
Copy link
Contributor

Duplicate of #269

@dougwilson dougwilson marked this as a duplicate of #269 Jul 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants