Skip to content

Commit faaa68a

Browse files
authored
enhance the method of path.basename
value.client._httpMessage.path maybe return undefined, and cause error: `TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined`。 Add `|| ''` to enhance quality。
1 parent b16916a commit faaa68a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/form_data.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ FormData.prototype._getContentDisposition = function(value, options) {
230230
filename = path.basename(options.filename || value.name || value.path);
231231
} else if (value.readable && value.hasOwnProperty('httpVersion')) {
232232
// or try http response
233-
filename = path.basename(value.client._httpMessage.path);
233+
filename = path.basename(value.client._httpMessage.path || '');
234234
}
235235

236236
if (filename) {

0 commit comments

Comments
 (0)