Hey is a decentralized and permissionless social media app built with Lens Protocol 🌿

Refactor getFavicon helper (#5644)

authored by yoginth.com and committed by

GitHub f769a7b8 719c0ee9

+10 -3
+10 -3
apps/web/src/helpers/getFavicon.ts
··· 1 - const getFavicon = (url: string) => { 1 + const FAVICON_BASE_URL = "https://external-content.duckduckgo.com/ip3"; 2 + const UNKNOWN_DOMAIN = "unknowndomain"; 3 + 4 + const getFavicon = (url: string): string => { 5 + if (!url) { 6 + return `${FAVICON_BASE_URL}/${UNKNOWN_DOMAIN}.ico`; 7 + } 8 + 2 9 try { 3 10 const { hostname } = new URL(url); 4 - return `https://external-content.duckduckgo.com/ip3/${hostname || "unknowndomain"}.ico`; 11 + return `${FAVICON_BASE_URL}/${hostname || UNKNOWN_DOMAIN}.ico`; 5 12 } catch { 6 - return "https://external-content.duckduckgo.com/ip3/unknowndomain.ico"; 13 + return `${FAVICON_BASE_URL}/${UNKNOWN_DOMAIN}.ico`; 7 14 } 8 15 }; 9 16