From cfb565902090caeacdb5310f599317691c351ddc Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 21 Feb 2026 15:05:22 -0600 Subject: [PATCH] Replace DomainFavicon with ExternalFavicon using configurable favicon URL template The old DomainFavicon component had a multi-step fallback chain (HTML scraping, direct URL guessing, then the configured provider) which meant the configurable setting was almost never reached. The new ExternalFavicon component uses the configured favicon URL template directly via RFC 6570 URI templates. - Rename config field faviconProvider -> faviconUrl - Add faviconUrl() utility with uri-templates for RFC 6570 support - Remove local Favicon component from ProfileRightSidebar - Update all consumers to use ExternalFavicon --- package-lock.json | 7 ++ package.json | 1 + src/App.tsx | 2 +- src/components/AdvancedSettings.tsx | 24 ++-- src/components/AppProvider.tsx | 2 +- src/components/DomainFavicon.tsx | 168 ------------------------- src/components/ExternalFavicon.tsx | 77 ++++++++++++ src/components/Nip05Badge.tsx | 4 +- src/components/ProfileHoverCard.tsx | 4 +- src/components/ProfileRightSidebar.tsx | 40 +----- src/contexts/AppContext.ts | 4 +- src/lib/faviconUrl.ts | 31 +++++ src/pages/DomainFeedPage.tsx | 4 +- src/pages/ProfilePage.tsx | 4 +- src/test/TestApp.tsx | 2 +- src/types/uri-templates.d.ts | 7 ++ 16 files changed, 151 insertions(+), 230 deletions(-) delete mode 100644 src/components/DomainFavicon.tsx create mode 100644 src/components/ExternalFavicon.tsx create mode 100644 src/lib/faviconUrl.ts create mode 100644 src/types/uri-templates.d.ts diff --git a/package-lock.json b/package-lock.json index 84713725..2c9d3903 100644 --- a/package-lock.json +++ b/package-lock.json @@ -72,6 +72,7 @@ "rehype-sanitize": "^6.0.0", "tailwind-merge": "^2.5.2", "tailwindcss-animate": "^1.0.7", + "uri-templates": "^0.2.0", "vaul": "^0.9.3", "zod": "^4.3.6" }, @@ -9755,6 +9756,12 @@ "punycode": "^2.1.0" } }, + "node_modules/uri-templates": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/uri-templates/-/uri-templates-0.2.0.tgz", + "integrity": "sha512-EWkjYEN0L6KOfEoOH6Wj4ghQqU7eBZMJqRHQnxQAq+dSEzRPClkWjf8557HkWQXF6BrAUoLSAyy9i3RVTliaNg==", + "license": "http://geraintluff.github.io/tv4/LICENSE.txt" + }, "node_modules/use-callback-ref": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/use-callback-ref/-/use-callback-ref-1.3.3.tgz", diff --git a/package.json b/package.json index 40798e71..bf3c785e 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "rehype-sanitize": "^6.0.0", "tailwind-merge": "^2.5.2", "tailwindcss-animate": "^1.0.7", + "uri-templates": "^0.2.0", "vaul": "^0.9.3", "zod": "^4.3.6" }, diff --git a/src/App.tsx b/src/App.tsx index 382c77fb..001b2597 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -69,7 +69,7 @@ const defaultConfig: AppConfig = { nip85OnlyMode: true, blossomServers: ['https://blossom.primal.net/'], defaultZapComment: 'Zapped with Mew!', - faviconProvider: 'https://favicon.shakespeare.diy/?url={href}', + faviconUrl: 'https://favicon.shakespeare.diy/?url={href}', corsProxy: 'https://proxy.shakespeare.diy/?url={href}', contentWarningPolicy: 'blur', }; diff --git a/src/components/AdvancedSettings.tsx b/src/components/AdvancedSettings.tsx index 346bc33f..03e0ac3a 100644 --- a/src/components/AdvancedSettings.tsx +++ b/src/components/AdvancedSettings.tsx @@ -22,7 +22,7 @@ export function AdvancedSettings() { const [statsPubkey, setStatsPubkey] = useState(config.nip85StatsPubkey); const [newBlossomUrl, setNewBlossomUrl] = useState(''); const [defaultZapComment, setDefaultZapComment] = useState(config.defaultZapComment); - const [faviconProvider, setFaviconProvider] = useState(config.faviconProvider); + const [faviconUrl, setFaviconUrl] = useState(config.faviconUrl); const [corsProxy, setCorsProxy] = useState(config.corsProxy); const handleAddBlossomServer = () => { @@ -352,25 +352,25 @@ export function AdvancedSettings() { - {/* Favicon Provider */} + {/* Favicon URL */}
-