From ef51d127b1e1a5182c6b7417012df661543d1814 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 19 Oct 2024 16:41:02 -0500 Subject: [PATCH] CryptoIcon: improve getIcon dynamic import --- src/features/crypto-donate/components/crypto-icon.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/features/crypto-donate/components/crypto-icon.tsx b/src/features/crypto-donate/components/crypto-icon.tsx index e829f9bbd..f135c3bc3 100644 --- a/src/features/crypto-donate/components/crypto-icon.tsx +++ b/src/features/crypto-donate/components/crypto-icon.tsx @@ -4,9 +4,11 @@ import genericIcon from 'soapbox/assets/cryptocurrency/generic.svg'; /** Get crypto icon URL by ticker symbol, or fall back to generic icon */ function getIcon(ticker: string): string { - const modules: Record = import.meta.glob('../../../assets/cryptocurrency/*.svg', { eager: true }); - const key = `../../../assets/cryptocurrency/${ticker}.svg`; - return modules[key]?.default || genericIcon; + try { + return new URL(`../../../assets/cryptocurrency/${ticker}.svg`, import.meta.url).href; + } catch { + return genericIcon; + } } interface ICryptoIcon {