Fix bug with data urls attempting to route to the favicon proxy.

This commit is contained in:
wearrrrr 2024-04-01 13:48:57 -05:00
parent e54858620b
commit f5fdaf32e6

View file

@ -227,15 +227,21 @@
(iframe.contentDocument.querySelector("link[rel='icon']") as HTMLLinkElement) || (iframe.contentDocument.querySelector("link[rel='icon']") as HTMLLinkElement) ||
(iframe.contentDocument.querySelector("link[rel*='icon']") as HTMLLinkElement); (iframe.contentDocument.querySelector("link[rel*='icon']") as HTMLLinkElement);
if (favicon && favicon.href) { if (favicon && favicon.href) {
if ( let encodedHREF = encodeURIComponent(favicon.href);
proxiedFavicon.src == if (favicon.href.includes("data:image")) {
`${window.location.origin}/custom-favicon?url=${encodeURIComponent(favicon.href)}` || proxiedFavicon.src = favicon.href;
hasErrored return;
) }
if (proxiedFavicon.src == `${window.location.origin}/custom-favicon?url=${encodedHREF}`)
return; return;
} }
if (favicon) { if (favicon) {
proxiedFavicon.src = `/custom-favicon?url=${encodeURIComponent(favicon.href)}`; let encodedHREF = encodeURIComponent(favicon.href);
if (favicon.href.includes("data:image")) {
proxiedFavicon.src = favicon.href;
return;
}
proxiedFavicon.src = `/custom-favicon?url=${encodedHREF}`;
proxiedFavicon.addEventListener("error", () => { proxiedFavicon.addEventListener("error", () => {
proxiedFavicon.src = "/favicon.ico"; proxiedFavicon.src = "/favicon.ico";
}); });