fix: url sanitization

This commit is contained in:
Han Xiao 2025-03-17 18:09:01 +08:00
parent 3930f8b863
commit 1ac80e4d20

View File

@ -24,6 +24,9 @@ export function normalizeUrl(urlString: string, debug = false, options = {
}
const url = new URL(urlString);
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
throw new Error('Unsupported protocol');
}
url.hostname = url.hostname.toLowerCase();
if (url.hostname.startsWith('www.')) {