Skip to content

Commit

Permalink
chore(nuxt): update to new hasProtocol options format (#19555)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Mar 9, 2023
1 parent d469740 commit 9a5e3e3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/nuxt/src/app/components/nuxt-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export function defineNuxtLink (options: NuxtLinkOptions) {
return false
}

return to.value === '' || hasProtocol(to.value, true)
return to.value === '' || hasProtocol(to.value, { acceptRelative: true })
})

// Prefetching
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/src/app/composables/payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function _getPayloadURL (url: string, opts: LoadPayloadOptions = {}) {
if (u.search) {
throw new Error('Payload URL cannot contain search params: ' + url)
}
if (u.host !== 'localhost' || hasProtocol(u.pathname, true)) {
if (u.host !== 'localhost' || hasProtocol(u.pathname, { acceptRelative: true })) {
throw new Error('Payload URL must not include hostname: ' + url)
}
const hash = opts.hash || (opts.fresh ? Date.now() : '')
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/src/app/composables/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const navigateTo = (to: RouteLocationRaw | undefined | null, options?: Na
}

const toPath = typeof to === 'string' ? to : ((to as RouteLocationPathRaw).path || '/')
const isExternal = hasProtocol(toPath, true)
const isExternal = hasProtocol(toPath, { acceptRelative: true })
if (isExternal && !options?.external) {
throw new Error('Navigating to external URL is not allowed by default. Use `navigateTo (url, { external: true })`.')
}
Expand Down

0 comments on commit 9a5e3e3

Please sign in to comment.