diff --git a/lib/stringify.js b/lib/stringify.js index 72ded14a..fcf5cc8f 100644 --- a/lib/stringify.js +++ b/lib/stringify.js @@ -75,7 +75,12 @@ var stringify = function stringify( } else if (obj instanceof Date) { obj = serializeDate(obj); } else if (generateArrayPrefix === 'comma' && isArray(obj)) { - obj = obj.join(','); + obj = utils.maybeMap(obj, function (value) { + if (value instanceof Date) { + return serializeDate(value); + } + return value; + }).join(','); } if (obj === null) { diff --git a/test/stringify.js b/test/stringify.js index 760d08cb..49692184 100644 --- a/test/stringify.js +++ b/test/stringify.js @@ -595,6 +595,18 @@ test('stringify()', function (t) { 'custom serializeDate function called' ); + st.equal( + qs.stringify( + { a: [date] }, + { + serializeDate: function (d) { return d.getTime(); }, + arrayFormat: 'comma' + } + ), + 'a=' + date.getTime(), + 'works with arrayFormat comma' + ); + st.end(); });