v3: fix to title extraction regex
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 38s

This commit is contained in:
khannurien
2026-06-21 20:40:10 +00:00
parent 981129c88d
commit 473f1046f3

View File

@@ -156,17 +156,17 @@ export function extractOgTag(
): string | undefined {
const patterns = [
new RegExp(
`<meta[^>]+property=["']og:${tag}["'][^>]+content=["']([^"']+)["']`,
`<meta[^>]+property=["']og:${tag}["'][^>]+content=(["'])([\\s\\S]*?)\\1`,
"i",
),
new RegExp(
`<meta[^>]+content=["']([^"']+)["'][^>]+property=["']og:${tag}["']`,
`<meta[^>]+content=(["'])([\\s\\S]*?)\\1[^>]+property=["']og:${tag}["']`,
"i",
),
];
for (const pattern of patterns) {
const match = html.match(pattern);
if (match) return decodeHtmlEntities(match[1]);
if (match) return decodeHtmlEntities(match[2]);
}
return undefined;
}
@@ -179,17 +179,17 @@ export function extractMetaName(
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const patterns = [
new RegExp(
`<meta[^>]+name=["']${escaped}["'][^>]+content=["']([^"']+)["']`,
`<meta[^>]+name=["']${escaped}["'][^>]+content=(["'])([\\s\\S]*?)\\1`,
"i",
),
new RegExp(
`<meta[^>]+content=["']([^"']+)["'][^>]+name=["']${escaped}["']`,
`<meta[^>]+content=(["'])([\\s\\S]*?)\\1[^>]+name=["']${escaped}["']`,
"i",
),
];
for (const pattern of patterns) {
const match = html.match(pattern);
if (match) return decodeHtmlEntities(match[1]);
if (match) return decodeHtmlEntities(match[2]);
}
return undefined;
}