From 6f4b3a4e4428fda0c5e63f6d862ad15262a71f7f Mon Sep 17 00:00:00 2001 From: MillenniumEarl Date: Sat, 12 Dec 2020 13:41:39 +0100 Subject: [PATCH] Reduce cyclomatic complexity --- app/scripts/network-helper.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/scripts/network-helper.js b/app/scripts/network-helper.js index 9fa9a25..2f72867 100644 --- a/app/scripts/network-helper.js +++ b/app/scripts/network-helper.js @@ -39,18 +39,23 @@ const commonConfig = { * @returns {Promise} HTML code or `null` if an error arise */ module.exports.fetchHTML = async function (url) { + // Local variables + let returnValue = null; + // Fetch the response of the platform const response = await exports.fetchGETResponse(url); + + // Manage response if (!response) { shared.logger.warn(`Unable to fetch HTML for ${url}`); - return null; } else if (!response.headers["content-type"].includes("text/html")) { // The response is not a HTML page shared.logger.warn(`The ${url} returned a ${response.headers["content-type"]} response`); - return null; } - return response.data; + + returnValue = response.data; + return returnValue; }; /**