generated from Dicken/dickendock
Bugfixes (Dark Mode, Dropdown-Kontrast, IP-Suche), Lesezeichen-Ausbau (Farbe, Beschreibung, Favicon), Zuletzt-besucht, Spaeter-lesen, kombinierter Import-Export, Scanner-Reconciliation, Admin-Ueberarbeitung
This commit is contained in:
@@ -6,6 +6,7 @@ export interface HttpProbeResult {
|
||||
status?: number;
|
||||
title?: string;
|
||||
faviconUrl?: string;
|
||||
description?: string;
|
||||
server?: string;
|
||||
bodySnippet?: string;
|
||||
}
|
||||
@@ -46,6 +47,7 @@ export function probeHttp(baseUrl: string, timeoutMs = 2000): Promise<HttpProbeR
|
||||
status: res.statusCode,
|
||||
title: extractTitle(body),
|
||||
faviconUrl: extractFaviconUrl(body, baseUrl),
|
||||
description: extractDescription(body),
|
||||
server: Array.isArray(serverHeader) ? serverHeader[0] : serverHeader,
|
||||
bodySnippet: body,
|
||||
});
|
||||
@@ -82,3 +84,12 @@ function extractFaviconUrl(html: string, baseUrl: string): string | undefined {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function extractDescription(html: string): string | undefined {
|
||||
// <meta name="description" content="..."> in beiden Attribut-Reihenfolgen
|
||||
const match =
|
||||
html.match(/<meta[^>]+name=["']description["'][^>]+content=["']([^"']*)["']/i) ??
|
||||
html.match(/<meta[^>]+content=["']([^"']*)["'][^>]+name=["']description["']/i);
|
||||
const description = match?.[1]?.trim();
|
||||
return description ? description : undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user