From 959f6c90f35dadfd094edd3340bb7ec9396c5234 Mon Sep 17 00:00:00 2001 From: cubemaster21 Date: Tue, 13 Jun 2023 10:50:38 -0400 Subject: [PATCH] parsing base64 --- processors/superstockamx.processor.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/processors/superstockamx.processor.js b/processors/superstockamx.processor.js index 3d33d30..0b191a3 100644 --- a/processors/superstockamx.processor.js +++ b/processors/superstockamx.processor.js @@ -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:(?[^;]+);base64,(?.+)/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 };