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

fix: nested repeated array syntax #43

Merged
merged 1 commit into from
Jun 25, 2024
Merged

fix: nested repeated array syntax #43

merged 1 commit into from
Jun 25, 2024

Conversation

43081j
Copy link
Owner

@43081j 43081j commented Jun 25, 2024

Fixes #42

Essentially we had two bugs 👀

Bug 1: if you have repeat syntax when using bracket-notation, but only had one key, we would not create it as an array.

For example:

parse('foo[]=1', opts); // {foo: 1} - wrong!

parse('foo[]=1&foo[]=2', opts); // {foo: [1, 2]} - right!

Bug 2: if you have repeat syntax following an index-nested member, we would not parse it correctly.

For example:

parse('foo[bar][]=1', opts); // {foo: {bar: 1}} - wrong!

// expected: {foo: {bar: [1]}}

These should both now be fixed.

cc @TheDevMinerTV

Fixes #42

Essentially we had two bugs 👀

Bug 1: if you have repeat syntax when using bracket-notation, but only
had one key, we would _not_ create it as a string.

For example:

```ts
parse('foo[]=1', opts); // {foo: 1} - wrong!

parse('foo[]=1&foo[]=2', opts); // {foo: [1, 2]} - right!
```

Bug 2: if you have repeat syntax following an index-nested member, we
would not parse it correctly.

For example:

```ts
parse('foo[bar][]=1', opts); // {foo: {bar: 1}} - wrong!

// expected: {foo: {bar: [1]}}
```

These should both now be fixed.
@43081j 43081j merged commit 5d0a39f into main Jun 25, 2024
3 checks passed
@43081j 43081j deleted the repeat-nested branch June 25, 2024 16:18
43081j added a commit that referenced this pull request Jun 25, 2024
fix: nested repeated array syntax (#43)
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

Successfully merging this pull request may close these issues.

Compatibility to qs
1 participant