Skip to content

Commit

Permalink
fix: add image type in blob used in getDataUrlFromB64Img
Browse files Browse the repository at this point in the history
  • Loading branch information
catalan-adobe committed May 25, 2023
1 parent 893d427 commit 4fa0937
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/utils/DOMUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,13 @@ export default class DOMUtils {
static getDataUrlFromB64Img(src) {
try {
const arr = src.split(',');
const bstr = atob(arr[1]);
let n = bstr.length - 1;
const u8arr = new Uint8Array(n);
while (n >= 0) {
u8arr[n] = bstr.charCodeAt(n);
n -= 1;
const type = arr[0].split(':')[1];
const b64Str = atob(arr[1]);
const bytesArray = new Uint8Array(b64Str.length);
for (let i = 0; i < b64Str.length; i += 1) {
bytesArray[i] = b64Str.charCodeAt(i);
}
const blob = new Blob([u8arr]);
const blob = new Blob([bytesArray], { type });
return URL.createObjectURL(blob);
} catch (e) {
// eslint-disable-next-line no-console
Expand Down

0 comments on commit 4fa0937

Please sign in to comment.