From ba5d3c4931bd522e82a17691ff96eca8578a80b5 Mon Sep 17 00:00:00 2001 From: lowlighter <22963968+lowlighter@users.noreply.github.com> Date: Mon, 23 Jan 2023 18:12:34 -0500 Subject: [PATCH] fix(app/metrics/utils): support base64 svg [skip ci] --- source/app/metrics/utils.mjs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/app/metrics/utils.mjs b/source/app/metrics/utils.mjs index ea06ddc77fd..74aa0441a10 100644 --- a/source/app/metrics/utils.mjs +++ b/source/app/metrics/utils.mjs @@ -451,6 +451,9 @@ export async function imgb64(image, {width, height, fallback = true} = {}) { //Undefined image if (!image) return fallback ? "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mOcOnfpfwAGfgLYttYINwAAAABJRU5ErkJggg==" : null + //SVG image + if ((typeof image === "string") && (image.endsWith(".svg"))) + return `data:image/svg+xml;base64,${Buffer.from(await fetch(image).then(response => response.arrayBuffer())).toString("base64")}` //Load image let ext = "png" try {