v3: fix to title extraction regex
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 38s
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 38s
This commit is contained in:
@@ -156,17 +156,17 @@ export function extractOgTag(
|
|||||||
): string | undefined {
|
): string | undefined {
|
||||||
const patterns = [
|
const patterns = [
|
||||||
new RegExp(
|
new RegExp(
|
||||||
`<meta[^>]+property=["']og:${tag}["'][^>]+content=["']([^"']+)["']`,
|
`<meta[^>]+property=["']og:${tag}["'][^>]+content=(["'])([\\s\\S]*?)\\1`,
|
||||||
"i",
|
"i",
|
||||||
),
|
),
|
||||||
new RegExp(
|
new RegExp(
|
||||||
`<meta[^>]+content=["']([^"']+)["'][^>]+property=["']og:${tag}["']`,
|
`<meta[^>]+content=(["'])([\\s\\S]*?)\\1[^>]+property=["']og:${tag}["']`,
|
||||||
"i",
|
"i",
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
for (const pattern of patterns) {
|
for (const pattern of patterns) {
|
||||||
const match = html.match(pattern);
|
const match = html.match(pattern);
|
||||||
if (match) return decodeHtmlEntities(match[1]);
|
if (match) return decodeHtmlEntities(match[2]);
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@@ -179,17 +179,17 @@ export function extractMetaName(
|
|||||||
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||||
const patterns = [
|
const patterns = [
|
||||||
new RegExp(
|
new RegExp(
|
||||||
`<meta[^>]+name=["']${escaped}["'][^>]+content=["']([^"']+)["']`,
|
`<meta[^>]+name=["']${escaped}["'][^>]+content=(["'])([\\s\\S]*?)\\1`,
|
||||||
"i",
|
"i",
|
||||||
),
|
),
|
||||||
new RegExp(
|
new RegExp(
|
||||||
`<meta[^>]+content=["']([^"']+)["'][^>]+name=["']${escaped}["']`,
|
`<meta[^>]+content=(["'])([\\s\\S]*?)\\1[^>]+name=["']${escaped}["']`,
|
||||||
"i",
|
"i",
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
for (const pattern of patterns) {
|
for (const pattern of patterns) {
|
||||||
const match = html.match(pattern);
|
const match = html.match(pattern);
|
||||||
if (match) return decodeHtmlEntities(match[1]);
|
if (match) return decodeHtmlEntities(match[2]);
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user