From 636f50c750f7e9f2a05df10bda201d4bae044175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemen=20Tu=C5=A1ar?= Date: Sun, 19 May 2024 11:23:31 +0100 Subject: [PATCH] chore: re-apply test --- test/parse.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/parse.js b/test/parse.js index f63c51cb..8724b2cc 100644 --- a/test/parse.js +++ b/test/parse.js @@ -571,6 +571,15 @@ test('parse()', function (t) { st.end(); }); + t.test('parses url-encoded brackets holds array of arrays when having two parts of strings with comma as array divider', function (st) { + st.deepEqual(qs.parse('foo%5B%5D=1,2,3&foo%5B%5D=4,5,6', { comma: true }), { foo: [['1', '2', '3'], ['4', '5', '6']] }); + st.deepEqual(qs.parse('foo%5B%5D=1,2,3&foo%5B%5D=', { comma: true }), { foo: [['1', '2', '3'], ''] }); + st.deepEqual(qs.parse('foo%5B%5D=1,2,3&foo%5B%5D=,', { comma: true }), { foo: [['1', '2', '3'], ['', '']] }); + st.deepEqual(qs.parse('foo%5B%5D=1,2,3&foo%5B%5D=a', { comma: true }), { foo: [['1', '2', '3'], 'a'] }); + + st.end(); + }); + t.test('parses comma delimited array while having percent-encoded comma treated as normal text', function (st) { st.deepEqual(qs.parse('foo=a%2Cb', { comma: true }), { foo: 'a,b' }); st.deepEqual(qs.parse('foo=a%2C%20b,d', { comma: true }), { foo: ['a, b', 'd'] });