fix: show branded icons for UA-inferred referrers instead of broken favicons

Plain name referrers like "Instagram" or "WhatsApp" (inferred from
User-Agent) were being passed to the favicon service as invalid
domains, returning a generic globe. Now skips favicon fetch for
any referrer without a dot, falling through to Phosphor icons.
This commit is contained in:
Usman Baig
2026-03-12 12:31:21 +01:00
parent 7bd922a012
commit 3fc0dec9d9

View File

@@ -218,6 +218,8 @@ export function getReferrerFavicon(referrer: string): string | null {
if (!referrer || typeof referrer !== 'string') return null
const normalized = referrer.trim().toLowerCase()
if (REFERRER_NO_FAVICON.includes(normalized)) return null
// Plain names without a dot (e.g. "Instagram", "WhatsApp") are not real domains
if (!normalized.includes('.')) return null
try {
const url = new URL(referrer.startsWith('http') ? referrer : `https://${referrer}`)
if (REFERRER_USE_X_ICON.has(url.hostname.toLowerCase())) return null