parsing base64

master
Edward Peterson 3 years ago
parent d5a71ed1f9
commit 959f6c90f3

@ -12,7 +12,15 @@ module.exports = {
if(src.includes('base64')) {
//base 64 pasted image
console.log('Found base64 image.')
return {base64: src};
const regex = /^data:(?<contentType>[^;]+);base64,(?<data>.+)/g;
const matches = data.matchAll(regex);
const groups = Array.from(matches, m => m.groups)[0]
return {base64: groups.data,
contentType: groups.contentType};
} else if(src.startsWith('http')) {
return { url: src };

Loading…
Cancel
Save