-
Notifications
You must be signed in to change notification settings - Fork 32
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
feat(xhr-api): Handle "blob" response types in intercepted XHR requests #151
feat(xhr-api): Handle "blob" response types in intercepted XHR requests #151
Conversation
@christian-bromann @chmanie thoughts? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
I guess the dropped support for IE should be mentioned somewhere, also this is a breaking change and should require a major version bump. |
@chmanie I wasn't sure the implementation would be amenable, so I hadn't made those changes. I'm not sure if there's a single way to convert blob response types in IE and in modern browsers as well, perhaps there is some solution using FileReader and another callback level. Alternately, if a Babel transpilation step were used, the use of modern JavaScript could be applied throughout the library without sacrificing compatibility. Adding a Babel transpile step isn't really the point of this PR, so I didn't want to pollute its purpose with another change. edit: I filed #152 (comment) as a way to help improve this process (though first-time contributors such as myself won't be notified until CICD stage is manually started). |
Are we breaking IE because of the use of async/await? I don't mind avoiding it in favor of some indentation. |
@chmanie It's worth noting that if a website has polyfilled |
@chmanie should be IE-compatible now; i replaced async + await with a FileReader callback |
@tehhowch mind rebasing this branch? |
- Account for CRLF line endings instead of LF, and also changes to the file's contents
The test fails comparing the body, as Node receives `{}` for any blob instead of the true content.
- update event listener to support deferred body parsing - When a `Blob` response is detected, use a FileReader to convert it into an `ArrayBuffer` and then decode as text. - Modern browsers could use `async` functions to await the result of `Blob.arrayBuffer()`, but the `FileReader.readAsArrayBuffer` approach preserves the existing state of Internet Explorer compatibility.
722330c
to
bfe1631
Compare
@christian-bromann done! |
@christian-bromann can we release 4.2.0? tests are passing on |
Sure, thanks for pinging! |
Closes #144
I believe this implementation does require dropping all support for internet explorer, since the async/await syntax won't be supported by its JS runtime.