From f782bc5f06a139827c87969a144ef14d5159cfd8 Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Mon, 20 Aug 2018 17:40:00 +0100 Subject: [PATCH] Avoid global flag when looking for metadata using regexes --- Readability.js | 4 ++-- test/test-pages/blogger/expected-metadata.json | 2 +- test/test-pages/la-nacion/expected-metadata.json | 2 +- test/test-pages/links-in-tables/expected-metadata.json | 2 +- test/test-pages/mozilla-2/expected-metadata.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Readability.js b/Readability.js index daf3bdb..19638c1 100644 --- a/Readability.js +++ b/Readability.js @@ -1200,10 +1200,10 @@ Readability.prototype = { // Match "description", or Twitter's "twitter:description" (Cards) // in name attribute. - var namePattern = /^\s*((twitter)\s*:\s*)?(description|title)\s*$/gi; + var namePattern = /^\s*((twitter)\s*:\s*)?(description|title)\s*$/i; // Match Facebook's Open Graph title & description properties. - var propertyPattern = /^\s*og\s*:\s*(description|title)\s*$/gi; + var propertyPattern = /^\s*og\s*:\s*(description|title)\s*$/i; // Find description tags. this._forEachNode(metaElements, function(element) { diff --git a/test/test-pages/blogger/expected-metadata.json b/test/test-pages/blogger/expected-metadata.json index dd85659..b3b4bea 100644 --- a/test/test-pages/blogger/expected-metadata.json +++ b/test/test-pages/blogger/expected-metadata.json @@ -2,6 +2,6 @@ "title": "Open Verilog flow for Silego GreenPak4 programmable logic devices", "byline": null, "dir": "ltr", - "excerpt": "I've written a couple of posts in the past few months but they were all for the blog at work so I figured I'm long overdue for one on Silicon Exposed.", + "excerpt": "I've written a couple of posts in the past few months but they were all for the blog at work so I figured I'm long overdue for one on Silic...", "readerable": true } diff --git a/test/test-pages/la-nacion/expected-metadata.json b/test/test-pages/la-nacion/expected-metadata.json index db3ec5d..355e30d 100644 --- a/test/test-pages/la-nacion/expected-metadata.json +++ b/test/test-pages/la-nacion/expected-metadata.json @@ -1,6 +1,6 @@ { "title": "Una solución no violenta para la cuestión mapuche - 07.12.2017", "byline": null, - "excerpt": "Los pueblos indígenas reclaman por derechos que permanecen\n incumplidos, por eso es más eficiente canalizar la protesta que reprimirla", + "excerpt": "Una solución no violenta para la cuestión mapuche | Los pueblos indígenas reclaman por derechos que permanecen incumplidos, por eso es más eficiente canalizar la protesta que reprimirla - LA NACION", "readerable": true } diff --git a/test/test-pages/links-in-tables/expected-metadata.json b/test/test-pages/links-in-tables/expected-metadata.json index b1b58ff..679c3f9 100644 --- a/test/test-pages/links-in-tables/expected-metadata.json +++ b/test/test-pages/links-in-tables/expected-metadata.json @@ -2,6 +2,6 @@ "title": "Saving Data: Reducing the size of App Updates by 65%", "byline": null, "dir": "ltr", - "excerpt": "Posted by Andrew Hayden, Software Engineer on Google Play", + "excerpt": "Posted by Andrew Hayden, Software Engineer on Google Play Android users are downloading tens of billions of apps and games on Google Pla...", "readerable": true } diff --git a/test/test-pages/mozilla-2/expected-metadata.json b/test/test-pages/mozilla-2/expected-metadata.json index d2126a6..d0c1f84 100644 --- a/test/test-pages/mozilla-2/expected-metadata.json +++ b/test/test-pages/mozilla-2/expected-metadata.json @@ -2,6 +2,6 @@ "title": "Welcome to Firefox Developer Edition", "byline": null, "dir": "ltr", - "excerpt": "Get to know the features that make it the most complete browser for building the Web.", + "excerpt": "Built for those who build the Web. Introducing the only browser made for developers.", "readerable": false }