Skip to content

Commit

Permalink
Support arrays of fields (similar to busboy options.autoFields)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhigginsuom committed Feb 15, 2017
1 parent d68e4a1 commit cc07b11
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ module.exports = function(options) {

req.busboy.on('field', function(fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) {
req.body = req.body || {};
req.body[fieldname] = val;
var prev = req.body[fieldname];
if (!prev) return req.body[fieldname] = val;
if (Array.isArray(prev)) return prev.push(val);
req.body[fieldname] = [prev, val];
});

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

0 comments on commit cc07b11

Please sign in to comment.