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

fix: ensure Blob and File type are included in FormData #1467

Merged
merged 1 commit into from May 26, 2022

Conversation

petebacondarwin
Copy link
Contributor

When appending a Blob-like or File-like object to FormData,
the item is wrapped in a File object. But this was causing
any options, such as type to be hidden in the wrapped type
and not exposed at the top level.

This fix copies the approach used in formdata-polyfill and
so also node-fetch where the wrapped object is also passed
as the options argument when creating a new File object.

Fixes cloudflare/workers-sdk#1085

When appending a Blob-like or File-like object to FormData,
the item is wrapped in a `File` object. But this was causing
any options, such as `type` to be hidden in the wrapped type
and not exposed at the top level.

This fix copies the approach used in `formdata-polyfill` and
so also `node-fetch` where the wrapped object is also passed
as the `options` argument when creating a new `File` object.

Fixes cloudflare/workers-sdk#1085
@codecov-commenter
Copy link

codecov-commenter commented May 26, 2022

Codecov Report

Merging #1467 (5cc09aa) into main (6855006) will increase coverage by 0.02%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #1467      +/-   ##
==========================================
+ Coverage   94.52%   94.55%   +0.02%     
==========================================
  Files          49       49              
  Lines        4271     4276       +5     
==========================================
+ Hits         4037     4043       +6     
+ Misses        234      233       -1     
Impacted Files Coverage Δ
lib/fetch/formdata.js 96.70% <ø> (ø)
lib/mock/mock-utils.js 100.00% <0.00%> (ø)
lib/mock/mock-interceptor.js 100.00% <0.00%> (ø)
lib/fetch/file.js 86.36% <0.00%> (+2.27%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6855006...5cc09aa. Read the comment docs.

@petebacondarwin
Copy link
Contributor Author

I can't tell if the Node 16 Windows test is a flake or a real failure?

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM

the Windows v16 is actually failing for a reason. However it's unrelated to this PR.

@ronag
Copy link
Member

ronag commented May 26, 2022

Confirmed that Chrome has the same behaviour.

@ronag ronag merged commit a7669df into nodejs:main May 26, 2022
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.

Uploading image from online link to supabase always returns application/octet-stream
5 participants