@@ -57,7 +57,7 @@ FormData.prototype.append = function (field, value, options) {
57
57
var append = CombinedStream . prototype . append . bind ( this ) ;
58
58
59
59
// all that streamy business can't handle numbers
60
- if ( typeof value === 'number' ) {
60
+ if ( typeof value === 'number' || value == null ) {
61
61
value = String ( value ) ;
62
62
}
63
63
@@ -231,14 +231,14 @@ FormData.prototype._getContentDisposition = function (value, options) {
231
231
if ( typeof options . filepath === 'string' ) {
232
232
// custom filepath for relative paths
233
233
filename = path . normalize ( options . filepath ) . replace ( / \\ / g, '/' ) ;
234
- } else if ( options . filename || value . name || value . path ) {
234
+ } else if ( options . filename || ( value && ( value . name || value . path ) ) ) {
235
235
/*
236
236
* custom filename take precedence
237
237
* formidable and the browser add a name property
238
238
* fs- and request- streams have path property
239
239
*/
240
- filename = path . basename ( options . filename || value . name || value . path ) ;
241
- } else if ( value . readable && hasOwn ( value , 'httpVersion' ) ) {
240
+ filename = path . basename ( options . filename || ( value && ( value . name || value . path ) ) ) ;
241
+ } else if ( value && value . readable && hasOwn ( value , 'httpVersion' ) ) {
242
242
// or try http response
243
243
filename = path . basename ( value . client . _httpMessage . path || '' ) ;
244
244
}
@@ -256,17 +256,17 @@ FormData.prototype._getContentType = function (value, options) {
256
256
var contentType = options . contentType ;
257
257
258
258
// or try `name` from formidable, browser
259
- if ( ! contentType && value . name ) {
259
+ if ( ! contentType && value && value . name ) {
260
260
contentType = mime . lookup ( value . name ) ;
261
261
}
262
262
263
263
// or try `path` from fs-, request- streams
264
- if ( ! contentType && value . path ) {
264
+ if ( ! contentType && value && value . path ) {
265
265
contentType = mime . lookup ( value . path ) ;
266
266
}
267
267
268
268
// or if it's http-reponse
269
- if ( ! contentType && value . readable && hasOwn ( value , 'httpVersion' ) ) {
269
+ if ( ! contentType && value && value . readable && hasOwn ( value , 'httpVersion' ) ) {
270
270
contentType = value . headers [ 'content-type' ] ;
271
271
}
272
272
@@ -276,7 +276,7 @@ FormData.prototype._getContentType = function (value, options) {
276
276
}
277
277
278
278
// fallback to the default content type if `value` is not simple value
279
- if ( ! contentType && typeof value === 'object' ) {
279
+ if ( ! contentType && value && typeof value === 'object' ) {
280
280
contentType = FormData . DEFAULT_CONTENT_TYPE ;
281
281
}
282
282
0 commit comments