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

[impovement]: better output for { depth: 0 } option #246

Closed
everdimension opened this issue Jan 16, 2018 · 4 comments
Closed

[impovement]: better output for { depth: 0 } option #246

everdimension opened this issue Jan 16, 2018 · 4 comments

Comments

@everdimension
Copy link

Desired behavior:

qs.parse('items[a]=one&items[b]=two', { depth: 0 });
// —> { 'items[a]': 'one', 'items[b]': 'two' }

Current behavior:

qs.parse('items[a]=one&items[b]=two', { depth: 0 });
// –> { items: { '[a]': 'one', '[b]': 'two' } }

It seems to me that the current output is quite useless, but having a one-level-deep can be quite handy, for example, when dealing with form inputs.

@ljharb
Copy link
Owner

ljharb commented Jan 16, 2018

Hmm, there's no explicit tests for a depth value of zero.

To be honest, both of those look pretty useless to me; but I agree with you that the former is what I'd expect with a depth of zero. What do you get with depth: 1?

@everdimension
Copy link
Author

with { depth: 1 } you get { items: { a: 'one', b: 'two' } } as expected.

Would you accept a PR for depth: 0?

@ljharb
Copy link
Owner

ljharb commented Jan 17, 2018

I think a PR with associated tests would be great.

@ljharb
Copy link
Owner

ljharb commented Aug 16, 2019

This should be fixed by #326.

@ljharb ljharb closed this as completed Aug 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants