From 205ccc9661c44bad61db87c9bc58528255436d95 Mon Sep 17 00:00:00 2001 From: BlazeInferno64 <96913755+BlazeInferno64@users.noreply.github.com> Date: Fri, 10 Jan 2025 15:51:01 +0530 Subject: [PATCH] Delete src/utils/url.js --- src/utils/url.js | 69 ------------------------------------------------ 1 file changed, 69 deletions(-) delete mode 100644 src/utils/url.js diff --git a/src/utils/url.js b/src/utils/url.js deleted file mode 100644 index ff4c5d5..0000000 --- a/src/utils/url.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) 2024 BlazeInferno64 --> https://github.com/blazeinferno64. -// -// Author(s) -> BlazeInferno64 -// -// Last updated: 06/12/2024 - -"use strict"; - -const { processError } = require("./errors"); -const { URL } = require("url"); - -/** - * Represents a parsed URL. - * @typedef {Object} ParsedURL - * @property {string} hash - * @property {string} host - * @property {string} hostname - * @property {string} href - * @property {string} origin - * @property {string} password - * @property {string} pathname - * @property {string} protocol - * @property {string} search - * @property {URLSearchParams} searchParams - */ - -/** - * Checks whether a provided URL is valid or not. - * If valid it parses the URL to get various properties like host,path,etc. - * @param {string} url The URL to check. - * @returns {Promise} A promise that resolves with the parsed URL as an Object. - */ - -const parseThisURL = (url, method) => { - return new Promise((resolve, reject) => { - (async () => { - try { - if (!url) { - const error = new Error(`Empty URL Provided!`); - error.name = "Null_URL_Error"; - error.code = "ENULLURL" - error.message = `HTTP Request '${method}' failed due to empty URL!`; - error.input = null; - return reject(error); - } - const parsedURL = new URL(url); - const urlData = { - hash: parsedURL.hash, - host: parsedURL.host, - hostname: parsedURL.hostname, - href: parsedURL.href, - origin: parsedURL.origin, - password: parsedURL.password, - pathname: parsedURL.pathname, - protocol: parsedURL.protocol, - search: parsedURL.search, - searchParams: parsedURL.searchParams, - }; - return resolve(urlData); - } catch (error) { - return reject(await processError(error, url, false, false, false, method, reject)) - } - })(); - }); -}; - -module.exports = { - parseThisURL -} \ No newline at end of file