MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / svgBase64ToUrl

Function svgBase64ToUrl

scripts/magnify_image.js:1447–1459  ·  view source on GitHub ↗
(sgvBase64)

Source from the content-addressed store, hash-verified

1445 return from + (to - from) * speed;
1446}
1447function svgBase64ToUrl(sgvBase64) {
1448 try {
1449 if (!/^data:image\/svg/.test(sgvBase64)) throw new Error("Invalid SVG");
1450 const svgContent = atob(sgvBase64.split(",")[1]);
1451 const blob = new Blob([svgContent], { type: "image/svg+xml" });
1452 const url = URL.createObjectURL(blob);
1453 setTimeout(() => URL.revokeObjectURL(url), 6e4);
1454 return url;
1455 } catch (e) {
1456 console.log("ERROR: ", e);
1457 return null;
1458 }
1459}
1460function svgToBlobUrl(svg) {
1461 let url = URL.createObjectURL(new Blob([svg], { type: "image/svg+xml" }));
1462 return url;

Callers 1

createPreviewFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected