Skip to content

Commit

Permalink
fix: improve isFormDataLike compat
Browse files Browse the repository at this point in the history
Fixes: #1952
  • Loading branch information
ronag committed Feb 21, 2023
1 parent d04ec2b commit d0bd26a
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions lib/core/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,20 +375,17 @@ function ReadableStreamFrom (iterable) {

// The chunk should be a FormData instance and contains
// all the required methods.
function isFormDataLike (chunk) {
return (chunk &&
chunk.constructor && chunk.constructor.name === 'FormData' &&
typeof chunk === 'object' &&
(typeof chunk.append === 'function' &&
typeof chunk.delete === 'function' &&
typeof chunk.get === 'function' &&
typeof chunk.getAll === 'function' &&
typeof chunk.has === 'function' &&
typeof chunk.set === 'function' &&
typeof chunk.entries === 'function' &&
typeof chunk.keys === 'function' &&
typeof chunk.values === 'function' &&
typeof chunk.forEach === 'function')
function isFormDataLike (object) {
return (
object &&
typeof object === 'object' &&
typeof object.append === 'function' &&
typeof object.delete === 'function' &&
typeof object.get === 'function' &&
typeof object.getAll === 'function' &&
typeof object.has === 'function' &&
typeof object.set === 'function' &&
object[Symbol.toStringTag] === 'FormData'
)
}

Expand Down

0 comments on commit d0bd26a

Please sign in to comment.