Skip to content

Commit

Permalink
Update utils.js (#3342)
Browse files Browse the repository at this point in the history
update isFormdata,isArrayBuffer and isURLSearchParams, because value and Formdata(ArrayBuffer or URLSearchParams) are not the same Window sometimes.

Co-authored-by: Jay <jasonsaayman@gmail.com>
  • Loading branch information
fanguangyi and jasonsaayman committed Dec 22, 2021
1 parent 5431634 commit 716d5de
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/utils.js
Expand Up @@ -54,7 +54,7 @@ function isArrayBuffer(val) {
* @returns {boolean} True if value is an FormData, otherwise false
*/
function isFormData(val) {
return (typeof FormData !== 'undefined') && (val instanceof FormData);
return toString.call(val) === '[object FormData]';
}

/**
Expand All @@ -68,7 +68,7 @@ function isArrayBufferView(val) {
if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
result = ArrayBuffer.isView(val);
} else {
result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
}
return result;
}
Expand Down Expand Up @@ -175,7 +175,7 @@ function isStream(val) {
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
*/
function isURLSearchParams(val) {
return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
return toString.call(val) === '[object URLSearchParams]';
}

/**
Expand Down

0 comments on commit 716d5de

Please sign in to comment.