Skip to content

Commit 0fc7f4a

Browse files
authored
fix: can't load the form-data polyfill in browsers because fs doesn't exist (#184)
1 parent 73d5000 commit 0fc7f4a

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/index.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
var debug = require('debug')('httpsnippet')
66
var es = require('event-stream')
77
var MultiPartForm = require('form-data')
8-
var FormDataPolyfill = require('form-data/lib/form_data')
98
var qs = require('querystring')
109
var reducer = require('./helpers/reducer')
1110
var targets = require('./targets')
@@ -128,7 +127,7 @@ HTTPSnippet.prototype.prepare = function (request) {
128127
// This hack is pretty awful but it's the only way we can use this library in the browser as if we code this
129128
// against just the native FormData object, we can't polyfill that back into Node because Blob and File objects,
130129
// which something like `formdata-polyfill` requires, don't exist there.
131-
const isNativeFormData = !(form instanceof FormDataPolyfill)
130+
const isNativeFormData = (typeof form[Symbol.iterator] === 'function')
132131

133132
// easter egg
134133
const boundary = '---011000010111000001101001'

0 commit comments

Comments
 (0)