Skip to content

Commit d33884e

Browse files
authored
fix: multiples should only affect multipart and urlencoded
1 parent 5d4dc40 commit d33884e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Formidable.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ class IncomingForm extends EventEmitter {
142142
const files = {};
143143

144144
this.on('field', (name, value) => {
145-
if (this.options.multiples) {
145+
if (this.options.multiples &&
146+
(this.type === 'multipart' || this.type === 'urlencoded')
147+
) {
146148
const mObj = { [name]: value };
147149
mockFields = `${mockFields}&${qs.stringify(mObj)}`;
148150
} else {

test/integration/test-json.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const testData = {
1111

1212
const PORT = 13532;
1313
const server = http.createServer((req, res) => {
14-
const form = formidable();
14+
const form = formidable({multiples: true});
1515

1616
form.parse(req, (err, fields) => {
1717
assert.deepStrictEqual(fields, {

0 commit comments

Comments
 (0)