@@ -7,6 +7,7 @@ var parseUrl = require('url').parse;
77var fs = require ( 'fs' ) ;
88var mime = require ( 'mime-types' ) ;
99var asynckit = require ( 'asynckit' ) ;
10+ var hasOwn = require ( 'hasown' ) ;
1011var setToStringTag = require ( 'es-set-tostringtag' ) ;
1112var populate = require ( './populate.js' ) ;
1213var Buffer = require ( 'safe-buffer' ) . Buffer ; // eslint-disable-line no-shadow
@@ -103,7 +104,7 @@ FormData.prototype._trackLength = function(header, value, options) {
103104 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 // take read range into a account
120121 // `end` = Infinity –> read file till the end
@@ -149,11 +150,11 @@ FormData.prototype._lengthRetriever = function(value, callback) {
149150 }
150151
151152 // or http response
152- } else if ( Object . prototype . hasOwnProperty . call ( value , 'httpVersion' ) ) {
153+ } else if ( hasOwn ( value , 'httpVersion' ) ) {
153154 callback ( null , + value . headers [ 'content-length' ] ) ;
154155
155156 // or request stream http://github.com/mikeal/request
156- } else if ( Object . prototype . hasOwnProperty . call ( value , 'httpModule' ) ) {
157+ } else if ( hasOwn ( value , 'httpModule' ) ) {
157158 // wait till response come back
158159 value . on ( 'response' , function ( response ) {
159160 value . pause ( ) ;
@@ -193,7 +194,7 @@ FormData.prototype._multiPartHeader = function(field, value, options) {
193194
194195 var header ;
195196 for ( var prop in headers ) {
196- if ( Object . prototype . hasOwnProperty . call ( headers , prop ) ) {
197+ if ( hasOwn ( headers , prop ) ) {
197198 header = headers [ prop ] ;
198199
199200 // skip nullish headers.
@@ -230,7 +231,7 @@ FormData.prototype._getContentDisposition = function(value, options) {
230231 // formidable and the browser add a name property
231232 // fs- and request- streams have path property
232233 filename = path . basename ( options . filename || value . name || value . path ) ;
233- } else if ( value . readable && Object . prototype . hasOwnProperty . call ( value , 'httpVersion' ) ) {
234+ } else if ( value . readable && hasOwn ( value , 'httpVersion' ) ) {
234235 // or try http response
235236 filename = path . basename ( value . client . _httpMessage . path || '' ) ;
236237 }
@@ -258,7 +259,7 @@ FormData.prototype._getContentType = function(value, options) {
258259 }
259260
260261 // or if it's http-reponse
261- if ( ! contentType && value . readable && Object . prototype . hasOwnProperty . call ( value , 'httpVersion' ) ) {
262+ if ( ! contentType && value . readable && hasOwn ( value , 'httpVersion' ) ) {
262263 contentType = value . headers [ 'content-type' ] ;
263264 }
264265
@@ -299,7 +300,7 @@ FormData.prototype.getHeaders = function(userHeaders) {
299300 } ;
300301
301302 for ( header in userHeaders ) {
302- if ( Object . prototype . hasOwnProperty . call ( userHeaders , header ) ) {
303+ if ( hasOwn ( userHeaders , header ) ) {
303304 formHeaders [ header . toLowerCase ( ) ] = userHeaders [ header ] ;
304305 }
305306 }
0 commit comments