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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error thrown on computing string sizes in FormData. #31

Closed
lonelam opened this issue Jul 18, 2022 · 1 comment 路 Fixed by #33
Closed

Error thrown on computing string sizes in FormData. #31

lonelam opened this issue Jul 18, 2022 · 1 comment 路 Fixed by #33

Comments

@lonelam
Copy link

lonelam commented Jul 18, 2022

Is this issue a feature request or a bug report?

馃悰Bug Report

What is the current behavior?
The script throws exception when sending post request on mock scene.
image

Inspecting stack trace of the error, the util function getStringByteLength in src/Utils.js seems using the native Blob to get the length of a string.

馃Step to reproduce

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

// inject mock-xmlhttprequest somewhere.
const formData = new FormData();
formData.append('name', 'some string in form');
axios.post('https://google.com/', formData, {}, {});

What is the expected behavior?

Maybe it should not throw the error?
Environment in which you encounter the issue:

  • mock-xmlhttprequest version: 7.0.4
  • Chrome version: Version 103.0.5060.114 (Official Build) (x86_64)
  • OS version: MacOS Big Sur

Did this work in a previous version of mock-xmlhttprequest (which)?
Have no idea about previous version of mock-xmlhttprequest.
Do you intend to provide a pull request to address this issue?

馃毀fixing PR

The issue is clear: we should use new Blob([string], {type: 'text/plain'}); to create a Blob according to latest
MDN document, I'm creating an PR for this bugfix.

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 a pull request may close this issue.

2 participants