From 02ba76f87d2f352cdaddc69c88c491726bad10f2 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Sat, 1 Jun 2024 10:08:07 +0800 Subject: [PATCH] fix: fail to display the thumbnail of some webpages * The regex we use is not strict and it will match og:image:type instead of og:image if there is one --- packages/readabilityjs/Readability.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/readabilityjs/Readability.js b/packages/readabilityjs/Readability.js index 44b698bc6..fb4eeefe9 100644 --- a/packages/readabilityjs/Readability.js +++ b/packages/readabilityjs/Readability.js @@ -1917,7 +1917,7 @@ Readability.prototype = { var metaElements = this._doc.getElementsByTagName("meta"); // property is a space-separated list of values - var propertyPattern = /\s*(dc|dcterm|og|twitter|article)\s*:\s*(locale|author|creator|description|title|site_name|published_time|published|date|image)\s*/gi; + var propertyPattern = /^\s*(dc|dcterm|og|twitter|article)\s*:\s*(locale|author|creator|description|title|site_name|published_time|published|date|image)\s*$/gi; // name is a single value var namePattern = /^\s*(?:(dc|dcterm|og|twitter|weibo:(article|webpage))\s*[\.:]\s*)?(author|creator|description|title|site_name|date|image)\s*$/i; @@ -2056,7 +2056,7 @@ Readability.prototype = { values["og:image"] || values["weibo:article:image"] || values["weibo:webpage:image"] || - jsonld.previewImage + jsonld.previewImage; metadata.locale = values["og:locale"];