From d278437a813809e8e3ecb2b94bf7fc057ea03a0a Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 11 Aug 2018 06:17:28 -0400 Subject: [PATCH] Only try 6 URLs from Unpaywall for a given DOI Hard to imagine needing more than that many tries, and some DOIs appear to have a huge number of URLs by mistake. --- chrome/content/zotero/xpcom/utilities_internal.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/chrome/content/zotero/xpcom/utilities_internal.js b/chrome/content/zotero/xpcom/utilities_internal.js index 9c68a494fe..1eac589c6b 100644 --- a/chrome/content/zotero/xpcom/utilities_internal.js +++ b/chrome/content/zotero/xpcom/utilities_internal.js @@ -957,6 +957,15 @@ Zotero.Utilities.Internal = { Zotero.debug(`Found ${urls.length} open-access PDF ${Zotero.Utilities.pluralize(urls.length, ['URL', 'URLs'])}`); // Handle older URL-only format urls = urls.map(o => typeof o == 'string' ? { url: o } : o); + + // Only try a small number of URLs, and ignore Unpaywall rows that have a huge number of + // URLs by mistake (as of August 2018) + let maxURLs = 6; + if (urls.length > maxURLs) { + Zotero.debug(`Keeping ${maxURLs} URLs`); + urls = urls.slice(0, maxURLs); + } + return urls; },