Skip to content

Commit

Permalink
Update utils.js (axios#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 authored Dec 22, 2021
1 parent 7b7442b commit ca39256
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/utils.js
Original file line number Diff line number Diff line change
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 ca39256

Please sign in to comment.