Skip to content

Commit

Permalink
Fix rendering of Uint8Array in node.js, where btoa exists as a top le…
Browse files Browse the repository at this point in the history
…vel function
papandreou committed Apr 25, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 1079255 commit 95d5405
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/magicPenMedia.js
Original file line number Diff line number Diff line change
@@ -73,7 +73,10 @@ module.exports = {
src = `data:${sanitizeContentType(contentType)};base64,`;
if (Buffer.isBuffer(media)) {
src += media.toString('base64');
} else if (media instanceof Uint8Array) {
src += Buffer.from(media).toString('base64');
} else if (typeof btoa === 'function') {
console.log('btoa');
src += btoa(media);
} else {
src += Buffer.from(media).toString('base64');

0 comments on commit 95d5405

Please sign in to comment.