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] Setter of request.query does not save array when length of the array is 1 #1672

Open
3jins opened this issue Jun 10, 2022 · 1 comment
Labels

Comments

@3jins
Copy link

3jins commented Jun 10, 2022

Describe the bug

Node.js version: 16.10.0

OS version: Mac OS Monterey 12.3.1 (It doesn't matter...)

Description:

Actual behavior

Setter of request.query saves single element instead of the array.

Setter of request.query uses qs.stringify to save the input to request.querystring, and it would be converted into the form like key=value1&key=value2.
But when array size is 1, it becomes unable to know whether it's array or string since it would be saved as key=value1.
So preprocessing would be necessary I think.

Expected behavior

An array should be saved as I passed.

Code to reproduce

  ctx.query = { tagIdList: ['abcd'] };
  console.log(ctx.query); // It prints out { tagIdList: 'abcd' }
@3jins 3jins added the bug label Jun 10, 2022
@miwnwski
Copy link
Member

miwnwski commented Jul 1, 2022

A solution was proposed in PR #1673

However, I'm tentatively holding any approvals as I judge this to require a semver major bump, in which case Koa could benefit from other changes as well.

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