Skip to content

Commit

Permalink
fix: Larger Size does not work in some websites
Browse files Browse the repository at this point in the history
  • Loading branch information
seadfeng committed Dec 12, 2024
1 parent b978f9e commit 92fab83
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ export const getFavicons = async ({ url, headers }: { url: string, headers?: Hea
const responseUrl = new URL(response.url);

// Regex to match <link> tags with "rel" containing "icon"
const regex = /<link[^>]*rel=['"][^'"]*icon[^'"]*['"][^>]*>/gi;
const regex = /<link[^>]*rel=['"]?[^\s]*icon['"]?[^>]*?>/gi;
const matches = Array.from(body.matchAll(regex));
const icons: { sizes: string, href: string }[] = [];

matches.forEach((match) => {
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) {
Expand Down

0 comments on commit 92fab83

Please sign in to comment.