mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
+19
-9
@@ -220,17 +220,27 @@ const isStream = (val) => isObject(val) && isFunction(val.pipe);
|
|||||||
*
|
*
|
||||||
* @returns {boolean} True if value is an FormData, otherwise false
|
* @returns {boolean} True if value is an FormData, otherwise false
|
||||||
*/
|
*/
|
||||||
|
function getGlobal() {
|
||||||
|
if (typeof globalThis !== 'undefined') return globalThis;
|
||||||
|
if (typeof self !== 'undefined') return self;
|
||||||
|
if (typeof window !== 'undefined') return window;
|
||||||
|
if (typeof global !== 'undefined') return global;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const G = getGlobal();
|
||||||
|
const FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
|
||||||
|
|
||||||
const isFormData = (thing) => {
|
const isFormData = (thing) => {
|
||||||
let kind;
|
let kind;
|
||||||
return (
|
return thing && (
|
||||||
thing &&
|
(FormDataCtor && thing instanceof FormDataCtor) || (
|
||||||
((typeof FormData === 'function' && thing instanceof FormData) ||
|
isFunction(thing.append) && (
|
||||||
(isFunction(thing.append) &&
|
(kind = kindOf(thing)) === 'formdata' ||
|
||||||
((kind = kindOf(thing)) === 'formdata' ||
|
// detect form-data instance
|
||||||
// detect form-data instance
|
(kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
|
||||||
(kind === 'object' &&
|
)
|
||||||
isFunction(thing.toString) &&
|
)
|
||||||
thing.toString() === '[object FormData]'))))
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user