fix(nuxt): provide default url for URL constructor

This commit is contained in:
Daniel Roe 2024-05-07 15:14:25 +01:00
parent bff1ec237b
commit 8bdd620ba1
No known key found for this signature in database
GPG Key ID: 3714AB03996F442B

View File

@ -140,7 +140,7 @@ export const navigateTo = (to: RouteLocationRaw | undefined | null, options?: Na
if (!options?.external) {
throw new Error('Navigating to an external URL is not allowed by default. Use `navigateTo(url, { external: true })`.')
}
const { protocol } = new URL(toPath)
const { protocol } = new URL(toPath, import.meta.client ? window.location.href : 'http://localhost')
if (protocol && isScriptProtocol(protocol)) {
throw new Error(`Cannot navigate to a URL with '${protocol}' protocol.`)
}