From 79e6b9ba8e166529450e8fab113be44765af4eea Mon Sep 17 00:00:00 2001 From: Pablo Hdez <62877300+pheralb@users.noreply.github.com> Date: Thu, 16 Mar 2023 11:26:23 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=20Create=20getSvgContent=20functio?= =?UTF-8?q?n.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/getSvgContent.ts | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/utils/getSvgContent.ts diff --git a/src/utils/getSvgContent.ts b/src/utils/getSvgContent.ts new file mode 100644 index 0000000..82d9b4b --- /dev/null +++ b/src/utils/getSvgContent.ts @@ -0,0 +1,7 @@ +export const MIMETYPE = 'text/plain'; +export const getSvgContent = async (url: string | undefined, isSupported: boolean) => { + const response = await fetch(url || ''); + const content = await response.text(); + const blob = new Blob([content], { type: MIMETYPE }); + return isSupported ? blob : content; +}; \ No newline at end of file