From 92fab835f70413ebbb02785c23070301d2e801d1 Mon Sep 17 00:00:00 2001 From: Sead Feng Date: Thu, 12 Dec 2024 14:17:56 +0800 Subject: [PATCH] fix: Larger Size does not work in some websites --- src/lib/server.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/server.ts b/src/lib/server.ts index 5c8ebde..5a11f0f 100644 --- a/src/lib/server.ts +++ b/src/lib/server.ts @@ -16,7 +16,7 @@ export const getFavicons = async ({ url, headers }: { url: string, headers?: Hea const responseUrl = new URL(response.url); // Regex to match tags with "rel" containing "icon" - const regex = /]*rel=['"][^'"]*icon[^'"]*['"][^>]*>/gi; + const regex = /]*rel=['"]?[^\s]*icon['"]?[^>]*?>/gi; const matches = Array.from(body.matchAll(regex)); const icons: { sizes: string, href: string }[] = []; @@ -24,11 +24,11 @@ export const getFavicons = async ({ url, headers }: { url: string, headers?: Hea const linkTag = match[0]; // Extract href value - const hrefMatch = linkTag.match(/href=['"](.*?)['"]/i); + const hrefMatch = linkTag.match(/href=['"]?([^\s>'"]*)['"]?/i); const href = hrefMatch ? hrefMatch[1] : null; // Extract sizes value - const sizesMatch = linkTag.match(/sizes=['"](.*?)['"]/i); + const sizesMatch = linkTag.match(/sizes=['"]?([^\s>'"]*)['"]?/i); const sizes = sizesMatch ? sizesMatch[1] : null; if (href) {