Reduce cyclomatic complexity
parent
0db26c6e26
commit
6f4b3a4e44
|
@ -39,18 +39,23 @@ const commonConfig = {
|
||||||
* @returns {Promise<String>} HTML code or `null` if an error arise
|
* @returns {Promise<String>} HTML code or `null` if an error arise
|
||||||
*/
|
*/
|
||||||
module.exports.fetchHTML = async function (url) {
|
module.exports.fetchHTML = async function (url) {
|
||||||
|
// Local variables
|
||||||
|
let returnValue = null;
|
||||||
|
|
||||||
// Fetch the response of the platform
|
// Fetch the response of the platform
|
||||||
const response = await exports.fetchGETResponse(url);
|
const response = await exports.fetchGETResponse(url);
|
||||||
|
|
||||||
|
// Manage response
|
||||||
if (!response) {
|
if (!response) {
|
||||||
shared.logger.warn(`Unable to fetch HTML for ${url}`);
|
shared.logger.warn(`Unable to fetch HTML for ${url}`);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
else if (!response.headers["content-type"].includes("text/html")) {
|
else if (!response.headers["content-type"].includes("text/html")) {
|
||||||
// The response is not a HTML page
|
// The response is not a HTML page
|
||||||
shared.logger.warn(`The ${url} returned a ${response.headers["content-type"]} response`);
|
shared.logger.warn(`The ${url} returned a ${response.headers["content-type"]} response`);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
return response.data;
|
|
||||||
|
returnValue = response.data;
|
||||||
|
return returnValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue