From c5c325c5947ea0d5d1ae0c75c57e3852da6b9e10 Mon Sep 17 00:00:00 2001 From: Srinivas Vaddi Date: Wed, 13 Aug 2025 01:49:56 -0400 Subject: [PATCH 1/2] refactor(url): remove is-url dependency and improve URL validation --- bin/utils/url.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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}`); } } From 9218efcfd19a240fd03bcf09a5cb205d16e83171 Mon Sep 17 00:00:00 2001 From: Srinivas Vaddi Date: Wed, 13 Aug 2025 02:01:12 -0400 Subject: [PATCH 2/2] refactor(dependencies): remove is-url and its type definitions --- package.json | 2 -- 1 file changed, 2 deletions(-) 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",