mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-20 07:30:57 +00:00
chore: prefer createRouteResolver
This commit is contained in:
parent
ad11d0299d
commit
6c6af8e2c0
@ -5,7 +5,7 @@ import { computed, defineComponent, h, inject, onBeforeUnmount, onMounted, provi
|
||||
import { hasProtocol, joinURL, parseQuery, parseURL } from 'ufo'
|
||||
import { preloadRouteComponents } from '../composables/preload'
|
||||
import { onNuxtReady } from '../composables/ready'
|
||||
import { createPathResolver, navigateTo, useRouter } from '../composables/router'
|
||||
import { createRouteResolver, navigateTo, useRouter } from '../composables/router'
|
||||
import { useNuxtApp, useRuntimeConfig } from '../nuxt'
|
||||
import { cancelIdleCallback, requestIdleCallback } from '../compat/idle-callback'
|
||||
|
||||
@ -150,7 +150,7 @@ export function defineNuxtLink (options: NuxtLinkOptions) {
|
||||
const router = useRouter()
|
||||
const config = useRuntimeConfig()
|
||||
|
||||
const resolvePath = createPathResolver( { trailingSlash: options?.trailingSlash })
|
||||
const resolvePath = createRouteResolver( { trailingSlash: options?.trailingSlash })
|
||||
|
||||
// Resolving `to` value from `to` and `href` props
|
||||
const to: ComputedRef<string | RouteLocationRaw> = computed(() => {
|
||||
|
@ -43,7 +43,7 @@ export const onBeforeRouteLeave = (guard: NavigationGuard) => {
|
||||
onScopeDispose(unsubscribe)
|
||||
}
|
||||
|
||||
export const createPathResolver = (options: {
|
||||
export const createRouteResolver = (options: {
|
||||
trailingSlash?: NuxtAppConfig['trailingSlash'],
|
||||
} = {}): RouteLocationRaw | RouteLocation => {
|
||||
options.trailingSlash = options.trailingSlash || appTrailingSlash
|
||||
@ -155,7 +155,7 @@ export const navigateTo = (to: RouteLocationRaw | undefined | null, options?: Na
|
||||
// normalise to a RouteLocationNamedRaw
|
||||
const route: RouteLocationPathRaw = typeof to === 'string' ? { path: to } : to
|
||||
const isExternal = options?.external || hasProtocol(route.path, { acceptRelative: true })
|
||||
const resolvePath = createPathResolver({
|
||||
const resolvePath = createRouteResolver({
|
||||
external: isExternal,
|
||||
})
|
||||
const resolvedPath = resolvePath(route)
|
||||
|
Loading…
Reference in New Issue
Block a user