update: isUrlInWhitelist

This commit is contained in:
xjccc 2025-02-19 14:53:00 +08:00
parent e59a350090
commit 992fbd8229

View File

@ -427,6 +427,7 @@ export function defineNuxtLink (options: NuxtLinkOptions) {
const target = props.target || null
function isUrlInWhitelist (url: string, whitelist: string[] = []): boolean {
if (!whitelist.length) { return false }
try {
const urlObj = new URL(url)
return whitelist.some(domain => urlObj.hostname.endsWith(domain))