export function applyFaviconToDom(url: string) { if (typeof document === 'undefined' || !url) return try { const next = new URL(url, window.location.href).href const existing = document.querySelectorAll('link[rel~="icon"]') if (existing.length === 1 && existing[0].href === next) return const link = document.createElement('link') link.rel = 'icon' link.href = url existing.forEach((l) => l.remove()) document.head.appendChild(link) } catch { // Ignore malformed URLs } }