Блоги #1

Merged
rndtrash merged 64 commits from feature-blogs into master 2025-10-22 08:44:56 +03:00
Showing only changes of commit 6a60ce55e5 - Show all commits

View file

@ -51,20 +51,20 @@ function getIconFromUrl(url: URL): string | undefined {
const hostname = url.hostname; const hostname = url.hostname;
const secondLevel = hostname.match(/(([A-Za-z0-9\-])+\.([A-Za-z0-9\-])+)$/)?.at(0) ?? ''; const secondLevel = hostname.match(/(([A-Za-z0-9\-])+\.([A-Za-z0-9\-])+)$/)?.at(0) ?? '';
if (specialResolvers[secondLevel]) if (specialResolvers[secondLevel])
return icons[specialResolvers[secondLevel](url)]; return specialResolvers[secondLevel](url);
return icons[hostname]; return hostname;
} }
export function tryGetIcon(link: string): string { export function tryGetIcon(link: string): string {
let url: URL; let url: URL;
try { try {
url = new URL(link); url = new URL(link, document.baseURI);
} catch { } catch {
return icons['none']; return icons['none'];
} }
return getIconFromUrl(url) ?? icons['none']; return icons[getIconFromUrl(url) ?? ''] ?? icons['none'];
} }
/** /**