File tree 1 file changed +26
-2
lines changed
1 file changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -469,7 +469,6 @@ Request.prototype._pipeContinue = function (stream, options) {
469
469
res . pipe ( stream , options ) ;
470
470
res . once ( 'end' , ( ) => this . emit ( 'end' ) ) ;
471
471
}
472
-
473
472
} ) ;
474
473
return stream ;
475
474
} ;
@@ -1093,7 +1092,7 @@ Request.prototype._end = function () {
1093
1092
parser = exports . parse . image ; // It's actually a generic Buffer
1094
1093
buffer = true ;
1095
1094
} else if ( multipart ) {
1096
- const form = formidable ( ) ;
1095
+ const form = formidable . formidable ( ) ;
1097
1096
parser = form . parse . bind ( form ) ;
1098
1097
buffer = true ;
1099
1098
} else if ( isBinary ( mime ) ) {
@@ -1162,6 +1161,31 @@ Request.prototype._end = function () {
1162
1161
}
1163
1162
1164
1163
if ( parserHandlesEnd ) {
1164
+ if ( multipart ) {
1165
+ // formidable v3 always returns an array with the value in it
1166
+ // so we need to flatten it
1167
+ if ( object ) {
1168
+ for ( const key in object ) {
1169
+ const value = object [ key ] ;
1170
+ if ( Array . isArray ( value ) && value . length === 1 ) {
1171
+ object [ key ] = value [ 0 ] ;
1172
+ } else {
1173
+ object [ key ] = value ;
1174
+ }
1175
+ }
1176
+ }
1177
+
1178
+ if ( files ) {
1179
+ for ( const key in files ) {
1180
+ const value = files [ key ] ;
1181
+ if ( Array . isArray ( value ) && value . length === 1 ) {
1182
+ files [ key ] = value [ 0 ] ;
1183
+ } else {
1184
+ files [ key ] = value ;
1185
+ }
1186
+ }
1187
+ }
1188
+ }
1165
1189
this . emit ( 'end' ) ;
1166
1190
this . callback ( null , this . _emitResponse ( object , files ) ) ;
1167
1191
}
You can’t perform that action at this time.
0 commit comments