Skip to content

Commit cc07b11

Browse files
committed
Support arrays of fields (similar to busboy options.autoFields)
1 parent d68e4a1 commit cc07b11

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/index.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ module.exports = function(options) {
1616

1717
req.busboy.on('field', function(fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) {
1818
req.body = req.body || {};
19-
req.body[fieldname] = val;
19+
var prev = req.body[fieldname];
20+
if (!prev) return req.body[fieldname] = val;
21+
if (Array.isArray(prev)) return prev.push(val);
22+
req.body[fieldname] = [prev, val];
2023
});
2124

2225
req.busboy.on('file', function(fieldname, file, filename, encoding, mimetype) {

0 commit comments

Comments
 (0)