From d7b7f7100a4e8f505a5dab5be22cbe9b995d19bc Mon Sep 17 00:00:00 2001 From: wwenrr Date: Wed, 1 Apr 2026 15:49:38 +0000 Subject: [PATCH] fix: preserve arrays for repeated query keys over 20 items --- lib/utils.js | 3 ++- test/req.query.js | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/utils.js b/lib/utils.js index 4f21e7ef1e3..23c2101de51 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -266,6 +266,7 @@ function createETagGenerator (options) { function parseExtendedQueryString(str) { return qs.parse(str, { - allowPrototypes: true + allowPrototypes: true, + arrayLimit: 1000 }); } diff --git a/test/req.query.js b/test/req.query.js index c0d3c8376e9..2003bf0b3f8 100644 --- a/test/req.query.js +++ b/test/req.query.js @@ -38,6 +38,17 @@ describe('req', function(){ .get('/?user.name=tj') .expect(200, '{"user.name":"tj"}', done); }); + + it('should parse repeated keys over 20 values as an array', function (done) { + var app = createApp('extended'); + var query = Array.from({ length: 21 }, function (_, i) { + return 'tenancyIds=' + (i + 1) + }).join('&') + + request(app) + .get('/?' + query) + .expect(200, '{"tenancyIds":["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21"]}', done); + }); }); describe('when "query parser" is simple', function () {