Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update types check #3342

Merged
merged 2 commits into from Dec 22, 2021
Merged

Update types check #3342

merged 2 commits into from Dec 22, 2021

Conversation

fanguangyi
Copy link
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

@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 <jasonsaayman@gmail.com>
@@ -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]';
Copy link

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

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

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.

None yet

4 participants