MCPcopy
hub / github.com/axios/axios / isFormData

Function isFormData

lib/utils.js:313–326  ·  view source on GitHub ↗
(thing)

Source from the content-addressed store, hash-verified

311const FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
312
313const isFormData = (thing) => {
314 if (!thing) return false;
315 if (FormDataCtor && thing instanceof FormDataCtor) return true;
316 // Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData.
317 const proto = getPrototypeOf(thing);
318 if (!proto || proto === Object.prototype) return false;
319 if (!isFunction(thing.append)) return false;
320 const kind = kindOf(thing);
321 return (
322 kind === 'formdata' ||
323 // detect form-data instance
324 (kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
325 );
326};
327
328/**
329 * Determine if a value is a URLSearchParams object

Callers

nothing calls this directly

Calls 2

getPrototypeOfFunction · 0.85
toStringMethod · 0.80

Tested by

no test coverage detected