fix: unnecessary eval

This commit is contained in:
Han Xiao 2025-03-18 21:07:33 +08:00
parent 1f248de100
commit f8decb037e

View File

@ -19,10 +19,14 @@ export function normalizeUrl(urlString: string, debug = false, options = {
throw new Error('Empty URL');
}
if (urlString.startsWith('https://google.com') || urlString.startsWith('https://www.google.com')) {
if (urlString.startsWith('https://google.com/') || urlString.startsWith('https://www.google.com')) {
throw new Error('Google search link');
}
if (urlString.includes('example.com')) {
throw new Error('Example URL');
}
const url = new URL(urlString);
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
throw new Error('Unsupported protocol');