Merge pull request #1015 from vaddisrinivas/main

fix(cli): replace is-url validation to support network hostnames like 'gateway'
This commit is contained in:
Tw93
2025-08-13 15:34:51 +08:00
committed by GitHub
2 changed files with 4 additions and 7 deletions

9
bin/utils/url.ts vendored
View File

@@ -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}`);
}
}

View File

@@ -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",