From 43f80f134b23fb01296cbca6f9f315d69ee7e547 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Tue, 8 Oct 2024 15:28:54 +0200 Subject: [PATCH] fix(nuxt): pass absolute external link urls to `link:prefetch` (#29321) --- packages/nuxt/src/app/components/nuxt-link.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/nuxt/src/app/components/nuxt-link.ts b/packages/nuxt/src/app/components/nuxt-link.ts index f38ddbd777..77006518a2 100644 --- a/packages/nuxt/src/app/components/nuxt-link.ts +++ b/packages/nuxt/src/app/components/nuxt-link.ts @@ -328,8 +328,9 @@ export function defineNuxtLink (options: NuxtLinkOptions) { const path = typeof to.value === 'string' ? to.value : isExternal.value ? resolveRouteObject(to.value) : router.resolve(to.value).fullPath + const normalizedPath = isExternal.value ? new URL(path, window.location.href).href : path await Promise.all([ - nuxtApp.hooks.callHook('link:prefetch', path).catch(() => {}), + nuxtApp.hooks.callHook('link:prefetch', normalizedPath).catch(() => {}), !isExternal.value && !hasTarget.value && preloadRouteComponents(to.value as string, router).catch(() => {}), ]) }