Warning when trying to fetch non-HTML response in fetchHTML

pull/57/head
MillenniumEarl 2020-11-30 10:39:59 +01:00
parent e3b83b81c8
commit 9ff4d6b12f
1 changed files with 5 additions and 0 deletions

View File

@ -42,6 +42,11 @@ module.exports.fetchHTML = async function (url) {
shared.logger.warn(`Unable to fetch HTML for ${url}`); shared.logger.warn(`Unable to fetch HTML for ${url}`);
return null; 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; return response.data;
}; };