Skip to content

Commit

Permalink
fix(app/metrics/utils): support base64 svg [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
lowlighter committed Jan 23, 2023
1 parent ec50393 commit ba5d3c4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions source/app/metrics/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit ba5d3c4

Please sign in to comment.