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

Pass custom parameters to qs #453

Open
AllanJard opened this issue Dec 15, 2021 · 3 comments
Open

Pass custom parameters to qs #453

AllanJard opened this issue Dec 15, 2021 · 3 comments

Comments

@AllanJard
Copy link

This is really the same as #98 but that issue has been locked. The original rational for not adding the ability to pass configuration parameters to qs was that package was abandoned. That is no longer the case and qs is now actively maintained. As such, I wonder if we might be able to revisit the original request and decision as that ability would be really useful.

Also released is #203 requesting support for custom parsers. That issue is perhaps less important since qs is maintained again?

The reason I'd like to see this, is that if I submit something like l-2[].dp-1 then the parameter in req.body is always l-2 regardless of what follows the []. (I think the same applies with just a .) due to the lack of support being able to set allowDots in qs.

@NakajimaTakuya
Copy link

I agree with him.
And in any case, I want to solve this problem as soon as possible, so I will fork body-parser in the meantime.
For future compatibility, I am curious to see if the library will take the generic parser as a solution or reorient itself in response to #453.
I would like to hear your thoughts once again.

@jybleau
Copy link

jybleau commented Oct 11, 2022

I created a fork that uses a new parameter: extendedOptions
https://github.com/jybleau/body-parser

Could or shoud it be considered as a PR?

I had parsing inconsistencies when using with Datatables Editor until I found out is was something that could be configured using qs options.

For instance, DT Editor by default uses an id, which is usually an integer, to identify objects and because of default array options in qs:

  • Sending this query string: data[2][name]=joe, results in: data: [{name: "joe"}] (data is an array)

But with a higher id number:

  • Sending this query string data[101][name]=joe2 results in: data: {"101": { name: "joe2" }} (data is now an object)

So it can result in an array or a plain object depending on the value of the number because the default limit for parsing an array is 100; above that threshold, it's parsed to an object.

In this case it's preferable to set qs not to parse arrays or have the array limit to 0.
So, would be nice to expose "advanced" qs options.

@jybleau
Copy link

jybleau commented Nov 23, 2022

@dougwilson, have there been any new thoughts on the idea of passing parameters to qs? Or should we still wait for a next major release for a new approach on this parsing "issue", so to speak.
Thanks !

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

4 participants