Skip to content

Commit b7a4323

Browse files
committed
fix(fetch-favicon): no longer default to ico
1 parent c8083f1 commit b7a4323

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/lib/fetch-favicon.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,17 @@ export async function fetchFavicon(
4848

4949
// fetch /favicon.ico
5050
{
51-
const faviconRes = await fetch(
52-
`${new URL(siteBaseURL).origin}/favicon.ico`,
53-
);
54-
const contentType =
55-
faviconRes.headers.get("content-type") ?? "image/vnd.microsoft.icon";
56-
if (faviconRes.ok && !contentType.startsWith("text/")) {
51+
const faviconUrl = `${new URL(siteBaseURL).origin}/favicon.ico`;
52+
const faviconRes = await fetch(faviconUrl);
53+
const contentType = faviconRes.headers.get("content-type");
54+
if (!contentType)
55+
console.warn(
56+
`header "Content-Type" not found while fetching ${faviconUrl}`,
57+
);
58+
if (
59+
faviconRes.ok &&
60+
(contentType == null || !contentType.startsWith("text/"))
61+
) {
5762
return base64DataURL(
5863
contentType,
5964
Buffer.from(await faviconRes.arrayBuffer()),

0 commit comments

Comments
 (0)