diff --git a/base.js b/base.js index ccbdb6e..f72e9a8 100644 --- a/base.js +++ b/base.js @@ -221,7 +221,7 @@ function parserForArrayFormat(options) { const arrayValue = value === null ? [] - : value.split(options.arrayFormatSeparator).map(item => decode(item, options)); + : decode(value, options).split(options.arrayFormatSeparator) if (accumulator[key] === undefined) { accumulator[key] = arrayValue; diff --git a/test/parse.js b/test/parse.js index 3409255..3b53844 100644 --- a/test/parse.js +++ b/test/parse.js @@ -215,6 +215,16 @@ test('query strings having a brackets+separator array and format option as `brac }), {foo: ['']}); }); +test('query strings having a brackets+separator array and format option as `bracket-separator` with a URL encoded value', t => { + t.deepEqual(queryString.parse('?testA%5B%5D=1&testB%5B%5D=a%2Cb%2Cc%2Cd%2Ce%2Cf&testC=true', { + arrayFormat: 'bracket-separator', + }), { + testA: ['1'], + testB: ['a', 'b', 'c', 'd', 'e', 'f'], + testC: 'true', + }); +}); + test('query strings having = within parameters (i.e. GraphQL IDs)', t => { t.deepEqual(queryString.parse('foo=bar=&foo=ba=z='), {foo: ['bar=', 'ba=z=']}); });