req.query will produce object instead of array when it contains more than 20 values in v4.22.X
bug4.x5.x
<!-- The process for bug fixing is:
- We will first assess if the behavior is different from what should occur
- Confirm the bug is reproducible
- Discuss how to best fix the bug
- Work towards a fix
-->
## Environment information
**Version**: 4.22.1 / 4.22.X
<!--
To find the installed version of a package, you can check the `package.json` file in the root directory of your project. The version will be listed under `dependencies` or `devDependencies`, like this:
```json
"dependencies": {
"express": "4.18.2"
}
-->
**Platform**: MacOS / Linux
<!--
UNIX: output of uname -a
Windows: output of "$([Environment]::OSVersion.VersionString) $(('x86', 'x64')[[Environment]::Is64BitOperatingSystem])" in PowerShell console
-->
**Node.js version**: 24.14.1
<!--
Output of node -v.
-->
**Any other relevant information**:
## What steps will reproduce the bug?
Consider following API query:
`GET /reports/download?tenancyIds=35&tenancyIds=28&tenancyIds=149&tenancyIds=157&tenancyIds=158&tenancyIds=159&tenancyIds=161&tenancyIds=160&tenancyIds=162&tenancyIds=163&tenancyIds=164&tenancyIds=165&tenancyIds=166&tenancyIds=167&tenancyIds=7&tenancyIds=196&tenancyIds=195&tenancyIds=198&tenancyIds=70&tenancyIds=6`
Prior to version 4.22.X, when calling with query regardless of numbers, `req.query.tenancyIds` will always produce as array:
```
[
'35', '28', '149', '157',
'158', '159', '161', '160',
'162', '163', '164', '165',
'166', '167', '7', '196',
'195', '198', '70', '6'
]
```
However, in version 4.22.X, when calling with query more than 20, `req.query.tenancyIds` will produce as object instead (but produce as array if it's 20 or less)
```
// 20 or less
[
'35', '28', '149', '157',
'158', '159', '161', '160',
'162', '163', '164', '165',
'166', '167', '7', '196',
'195', '198', '70', '6'
]
// more than 20
{
'0': '35',
'1': '28',
'2': '149',
'3': '157',
'4': '158',
'5': '159',
'6': '161',
'7': '160',
'8': '162',
'9': '163',
'10': '164',
'11': '165',
'12': '166',
'13': '167',
'14': '7',
'15': '196',
'16': '195',
'17': '198',
'18': '70',
'19': '6',
'20': '75'
}
```
2 条评论