diff --git a/bin/utils/url.ts b/bin/utils/url.ts index ec0350e..8f1a0ca 100644 --- a/bin/utils/url.ts +++ b/bin/utils/url.ts @@ -1,5 +1,4 @@ import * as psl from 'psl'; -import isUrl from 'is-url'; // Extracts the domain from a given URL. export function getDomain(inputUrl: string): string | null { @@ -32,10 +31,10 @@ export function appendProtocol(inputUrl: string): string { // Normalizes the URL by ensuring it has a protocol and is valid. export function normalizeUrl(urlToNormalize: string): string { const urlWithProtocol = appendProtocol(urlToNormalize); - - if (isUrl(urlWithProtocol)) { + try { + new URL(urlWithProtocol); return urlWithProtocol; - } else { - throw new Error(`Your url "${urlWithProtocol}" is invalid`); + } catch (err) { + throw new Error(`Your url "${urlWithProtocol}" is invalid: ${(err as Error).message}`); } } diff --git a/package.json b/package.json index aed48c6..42b7590 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,6 @@ "commander": "^11.1.0", "file-type": "^18.7.0", "fs-extra": "^11.2.0", - "is-url": "^1.2.4", "loglevel": "^1.9.2", "ora": "^7.0.1", "prompts": "^2.4.2", @@ -70,7 +69,6 @@ "@rollup/plugin-replace": "^5.0.7", "@rollup/plugin-terser": "^0.4.4", "@types/fs-extra": "^11.0.4", - "@types/is-url": "^1.2.32", "@types/node": "^20.17.10", "@types/page-icon": "^0.3.6", "@types/prompts": "^2.4.9",