From 23d7dea0bb52fdfc2686cc116fa3a02cd8f6d081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Thu, 7 Jan 2021 21:14:35 +0000 Subject: [PATCH] Improve WordPress detection --- lib/tools/redownload/redownload.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/tools/redownload/redownload.js b/lib/tools/redownload/redownload.js index 81270cc..d9238d6 100644 --- a/lib/tools/redownload/redownload.js +++ b/lib/tools/redownload/redownload.js @@ -753,14 +753,12 @@ var Redownload = function() { } function detectWordPress(requests) { - // Check the first file only - if (requests[0].isHTML && - requests[0].weightCheck.bodyBuffer && - requests[0].weightCheck.bodyBuffer.indexOf('/wp-content/') > 0) { - - return true; - } - return false; + // Check the first HTML file only + var htmlRequest = requests.find(function(request) { + return request.isHTML && request.weightCheck.bodyBuffer; + }); + + return htmlRequest && htmlRequest.weightCheck.bodyBuffer.indexOf('/wp-content/'); }