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(image): fix dataUri with type svg-base64 in browsers #3144

Merged
merged 6 commits into from
Sep 26, 2024

Conversation

ST-DDT
Copy link
Member

@ST-DDT ST-DDT commented Sep 25, 2024

Fixes #3143

Replaces the problematic Buffer.from(input).toString('base64') call with a custom replacement that also works in browsers.
Also adds an eslint rule that should prevent this error in the future.

Similar to the toBase64URL method from #2936

@ST-DDT ST-DDT added c: bug Something isn't working p: 1-normal Nothing urgent m: image Something is referring to the image module labels Sep 25, 2024
@ST-DDT ST-DDT added this to the v9.0 milestone Sep 25, 2024
@ST-DDT ST-DDT requested review from a team September 25, 2024 19:25
@ST-DDT ST-DDT self-assigned this Sep 25, 2024
Copy link

netlify bot commented Sep 25, 2024

Deploy Preview for fakerjs ready!

Name Link
🔨 Latest commit 88bcda9
🔍 Latest deploy log https://app.netlify.com/sites/fakerjs/deploys/66f583fa058fa000084c4007
😎 Deploy Preview https://deploy-preview-3144.fakerjs.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

eslint.config.ts Outdated Show resolved Hide resolved
Copy link

codecov bot commented Sep 25, 2024

Codecov Report

Attention: Patch coverage is 41.66667% with 7 lines in your changes missing coverage. Please review.

Project coverage is 99.97%. Comparing base (d6bceb6) to head (88bcda9).
Report is 1 commits behind head on next.

Files with missing lines Patch % Lines
src/internal/base64.ts 30.00% 7 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             next    #3144   +/-   ##
=======================================
  Coverage   99.97%   99.97%           
=======================================
  Files        2777     2778    +1     
  Lines      226355   226364    +9     
  Branches      945      946    +1     
=======================================
+ Hits       226288   226297    +9     
  Misses         67       67           
Files with missing lines Coverage Δ
src/modules/image/index.ts 100.00% <100.00%> (ø)
src/internal/base64.ts 30.00% <30.00%> (ø)

... and 1 file with indirect coverage changes

Copy link
Contributor

@matthewmayer matthewmayer left a comment

Choose a reason for hiding this comment

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

Could we use Buffer.from where available (as it's faster) and only fallback to the custom code when needed?

@ST-DDT ST-DDT requested review from xDivisionByZerox and a team September 26, 2024 15:55
@ST-DDT ST-DDT enabled auto-merge (squash) September 26, 2024 15:56
@ST-DDT ST-DDT merged commit 78b2a3a into next Sep 26, 2024
21 checks passed
@ST-DDT ST-DDT deleted the fix/image/dataUri/svg-base64 branch September 26, 2024 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: bug Something isn't working m: image Something is referring to the image module p: 1-normal Nothing urgent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants