mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
fix(nuxt): compatible route object for custom external routes (#19261)
This commit is contained in:
parent
9e6fa9f7ba
commit
f16cce8824
@ -1,7 +1,7 @@
|
||||
import type { PropType, DefineComponent, ComputedRef } from 'vue'
|
||||
import { defineComponent, h, ref, resolveComponent, computed, onMounted, onBeforeUnmount } from 'vue'
|
||||
import type { RouteLocationRaw } from 'vue-router'
|
||||
import { hasProtocol } from 'ufo'
|
||||
import { hasProtocol, parseQuery, parseURL } from 'ufo'
|
||||
|
||||
import { preloadRouteComponents } from '../composables/preload'
|
||||
import { onNuxtReady } from '../composables/ready'
|
||||
@ -250,10 +250,28 @@ export function defineNuxtLink (options: NuxtLinkOptions) {
|
||||
if (!slots.default) {
|
||||
return null
|
||||
}
|
||||
|
||||
return slots.default({
|
||||
href,
|
||||
navigate,
|
||||
route: router.resolve(href!),
|
||||
get route () {
|
||||
if (!href) { return undefined }
|
||||
|
||||
const url = parseURL(href)
|
||||
return {
|
||||
path: url.pathname,
|
||||
fullPath: url.pathname,
|
||||
get query () { return parseQuery(url.search) },
|
||||
hash: url.hash,
|
||||
// stub properties for compat with vue-router
|
||||
params: {},
|
||||
name: undefined,
|
||||
matched: [],
|
||||
redirectedFrom: undefined,
|
||||
meta: {},
|
||||
href
|
||||
}
|
||||
},
|
||||
rel,
|
||||
target,
|
||||
isExternal: isExternal.value,
|
||||
|
@ -40,7 +40,7 @@ describe.skipIf(isWindows)('minimal nuxt application', () => {
|
||||
|
||||
it('default server bundle size', async () => {
|
||||
stats.server = await analyzeSizes(['**/*.mjs', '!node_modules'], serverDir)
|
||||
expect(stats.server.totalBytes).toBeLessThan(92100)
|
||||
expect(stats.server.totalBytes).toBeLessThan(92700)
|
||||
|
||||
const modules = await analyzeSizes('node_modules/**/*', serverDir)
|
||||
expect(modules.totalBytes).toBeLessThan(2710200)
|
||||
|
Loading…
Reference in New Issue
Block a user