Skip to content

Commit

Permalink
fix: multiples should only affect multipart and urlencoded
Browse files Browse the repository at this point in the history
  • Loading branch information
GrosSacASac committed Jan 23, 2021
1 parent 5d4dc40 commit d33884e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Formidable.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ class IncomingForm extends EventEmitter {
const files = {};

this.on('field', (name, value) => {
if (this.options.multiples) {
if (this.options.multiples &&
(this.type === 'multipart' || this.type === 'urlencoded')
) {
const mObj = { [name]: value };
mockFields = `${mockFields}&${qs.stringify(mObj)}`;
} else {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/test-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const testData = {

const PORT = 13532;
const server = http.createServer((req, res) => {
const form = formidable();
const form = formidable({multiples: true});

form.parse(req, (err, fields) => {
assert.deepStrictEqual(fields, {
Expand Down

0 comments on commit d33884e

Please sign in to comment.