From 739c39b5f84e03bc6c58644e28bb1a650436f6db Mon Sep 17 00:00:00 2001 From: MillenniumEarl Date: Thu, 25 Feb 2021 17:14:31 +0100 Subject: [PATCH] Removed redundand JSDOC --- src/scripts/network-helper.ts | 15 ++++++++------- src/scripts/scrape-data/scrape-thread.ts | 1 - 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/scripts/network-helper.ts b/src/scripts/network-helper.ts index 7fe450b..03eba1e 100644 --- a/src/scripts/network-helper.ts +++ b/src/scripts/network-helper.ts @@ -30,7 +30,6 @@ const commonConfig = { /** * Gets the HTML code of a page. - * @returns {Promise} HTML code or `null` if an error arise */ export async function fetchHTML(url: string): Promise { // Local variables @@ -209,21 +208,23 @@ export async function getUrlRedirect(url: string): Promise { //#region Private methods /** - * @private * Check with Axios if a URL exists. - * @param {String} url */ async function axiosUrlExists(url: string): Promise { // Local variables + const ERROR_CODES = ["ENOTFOUND", "ETIMEDOUT"]; let valid = false; + try { - const response = await axios.head(url, {timeout: 3000}); + const response = await axios.head(url, { + timeout: 3000 + }); valid = response && !/4\d\d/.test(response.status.toString()); } catch (error) { - if (error.code === "ENOTFOUND") valid = false; - else if (error.code === "ETIMEDOUT") valid = false; - else throw error; + // Throw error only if the error is unknown + if (!ERROR_CODES.includes(error.code)) throw error; } + return valid; } //#endregion diff --git a/src/scripts/scrape-data/scrape-thread.ts b/src/scripts/scrape-data/scrape-thread.ts index 42a984c..572ea6c 100644 --- a/src/scripts/scrape-data/scrape-thread.ts +++ b/src/scripts/scrape-data/scrape-thread.ts @@ -275,7 +275,6 @@ function fillWithPostData(hw: HandiWork, elements: IPostElement[]) { /** * Gets the tags used to classify the game. * @param {cheerio.Cheerio} body Page `body` selector - * @returns {string[]} List of tags */ function extractTags(body: cheerio.Cheerio): string[] { shared.logger.trace("Extracting tags...");