@@ -10,6 +10,7 @@ var fs = require('fs');
1010var mime = require ( 'mime-types' ) ;
1111var asynckit = require ( 'asynckit' ) ;
1212var setToStringTag = require ( 'es-set-tostringtag' ) ;
13+ var hasOwn = require ( 'hasown' ) ;
1314var populate = require ( './populate.js' ) ;
1415
1516/**
@@ -103,7 +104,7 @@ FormData.prototype._trackLength = function (header, value, options) {
103104 this . _overheadLength += Buffer . byteLength ( header ) + FormData . LINE_BREAK . length ;
104105
105106 // empty or either doesn't have path or not an http response
106- if ( ! value || ( ! value . path && ! ( value . readable && Object . prototype . hasOwnProperty . call ( value , 'httpVersion' ) ) ) ) {
107+ if ( ! value || ( ! value . path && ! ( value . readable && hasOwn ( value , 'httpVersion' ) ) ) ) {
107108 return ;
108109 }
109110
@@ -114,7 +115,7 @@ FormData.prototype._trackLength = function (header, value, options) {
114115} ;
115116
116117FormData . prototype . _lengthRetriever = function ( value , callback ) {
117- if ( Object . prototype . hasOwnProperty . call ( value , 'fd' ) ) {
118+ if ( hasOwn ( value , 'fd' ) ) {
118119
119120 /*
120121 * take read range into a account
@@ -153,11 +154,11 @@ FormData.prototype._lengthRetriever = function (value, callback) {
153154 }
154155
155156 // or http response
156- } else if ( Object . prototype . hasOwnProperty . call ( value , 'httpVersion' ) ) {
157+ } else if ( hasOwn ( value , 'httpVersion' ) ) {
157158 callback ( null , Number ( value . headers [ 'content-length' ] ) ) ;
158159
159160 // or request stream http://github.com/mikeal/request
160- } else if ( Object . prototype . hasOwnProperty . call ( value , 'httpModule' ) ) {
161+ } else if ( hasOwn ( value , 'httpModule' ) ) {
161162 // wait till response come back
162163 value . on ( 'response' , function ( response ) {
163164 value . pause ( ) ;
@@ -199,7 +200,7 @@ FormData.prototype._multiPartHeader = function (field, value, options) {
199200
200201 var header ;
201202 for ( var prop in headers ) { // eslint-disable-line no-restricted-syntax
202- if ( Object . prototype . hasOwnProperty . call ( headers , prop ) ) {
203+ if ( hasOwn ( headers , prop ) ) {
203204 header = headers [ prop ] ;
204205
205206 // skip nullish headers.
@@ -236,7 +237,7 @@ FormData.prototype._getContentDisposition = function (value, options) {
236237 * fs- and request- streams have path property
237238 */
238239 filename = path . basename ( options . filename || value . name || value . path ) ;
239- } else if ( value . readable && Object . prototype . hasOwnProperty . call ( value , 'httpVersion' ) ) {
240+ } else if ( value . readable && hasOwn ( value , 'httpVersion' ) ) {
240241 // or try http response
241242 filename = path . basename ( value . client . _httpMessage . path || '' ) ;
242243 }
@@ -264,7 +265,7 @@ FormData.prototype._getContentType = function (value, options) {
264265 }
265266
266267 // or if it's http-reponse
267- if ( ! contentType && value . readable && Object . prototype . hasOwnProperty . call ( value , 'httpVersion' ) ) {
268+ if ( ! contentType && value . readable && hasOwn ( value , 'httpVersion' ) ) {
268269 contentType = value . headers [ 'content-type' ] ;
269270 }
270271
@@ -305,7 +306,7 @@ FormData.prototype.getHeaders = function (userHeaders) {
305306 } ;
306307
307308 for ( header in userHeaders ) { // eslint-disable-line no-restricted-syntax
308- if ( Object . prototype . hasOwnProperty . call ( userHeaders , header ) ) {
309+ if ( hasOwn ( userHeaders , header ) ) {
309310 formHeaders [ header . toLowerCase ( ) ] = userHeaders [ header ] ;
310311 }
311312 }
0 commit comments