Skip to content

Update types check#3342

Merged
jasonsaayman merged 2 commits intoaxios:masterfrom
fanguangyi:patch-1
Dec 22, 2021
Merged

Update types check#3342
jasonsaayman merged 2 commits intoaxios:masterfrom
fanguangyi:patch-1

Conversation

@fanguangyi
Copy link
Copy Markdown
Contributor

@fanguangyi fanguangyi commented Oct 16, 2020

update isFormdata,isArrayBuffer and isURLSearchParams, because value and Formdata(ArrayBuffer or URLSearchParams) are not in the same Window sometimes, such as iframe.

update isFormdata,isArrayBuffer and isURLSearchParams, because value and Formdata(ArrayBuffer or URLSearchParams) are not the same Window sometimes.
@chinesedfan chinesedfan changed the title Update utils.js Update types check Oct 17, 2020
@jasonsaayman jasonsaayman merged commit 716d5de into axios:master Dec 22, 2021
@chnliquan
Copy link
Copy Markdown

@jasonsaayman hi, when do you plan to release this change? I have a problem with this change.

mbargiel pushed a commit to mbargiel/axios that referenced this pull request Jan 27, 2022
update isFormdata,isArrayBuffer and isURLSearchParams, because value and Formdata(ArrayBuffer or URLSearchParams) are not the same Window sometimes.

Co-authored-by: Jay <[email protected]>
Comment thread lib/utils.js
*/
function isFormData(val) {
return (typeof FormData !== 'undefined') && (val instanceof FormData);
return toString.call(val) === '[object FormData]';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The result of toString.call(val) in my React Native project returns [object Object] rather than [object FormData] which makes file upload fail with this change. See #4412

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This issue seems related too: form-data/form-data#396

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString#using_tostring_to_detect_object_class using this way to detect object class is unreliable, so maybe it shouldn't be used?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants