mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
fix(nuxt): use URL
for parsing URLs rather than parseURL
This commit is contained in:
parent
5f0693a69a
commit
ea22d3f988
@ -8,7 +8,7 @@ import type {
|
||||
} from 'vue'
|
||||
import { computed, defineComponent, h, inject, onBeforeUnmount, onMounted, provide, ref, resolveComponent } from 'vue'
|
||||
import type { RouteLocation, RouteLocationRaw, Router, RouterLink, RouterLinkProps, useLink } from '#vue-router'
|
||||
import { hasProtocol, joinURL, parseQuery, parseURL, withTrailingSlash, withoutTrailingSlash } from 'ufo'
|
||||
import { hasProtocol, joinURL, parseQuery, withTrailingSlash, withoutTrailingSlash } from 'ufo'
|
||||
import { preloadRouteComponents } from '../composables/preload'
|
||||
import { onNuxtReady } from '../composables/ready'
|
||||
import { navigateTo, useRouter } from '../composables/router'
|
||||
@ -392,7 +392,7 @@ export function defineNuxtLink (options: NuxtLinkOptions) {
|
||||
get route () {
|
||||
if (!href.value) { return undefined }
|
||||
|
||||
const url = parseURL(href.value)
|
||||
const url = new URL(href.value, import.meta.client ? window.location.href : 'http://localhost')
|
||||
return {
|
||||
path: url.pathname,
|
||||
fullPath: url.pathname,
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { parseURL } from 'ufo'
|
||||
import { defineComponent, h } from 'vue'
|
||||
import { parseQuery } from 'vue-router'
|
||||
import { resolve } from 'pathe'
|
||||
@ -10,7 +9,7 @@ export default (url: string) => defineComponent({
|
||||
name: 'NuxtTestComponentWrapper',
|
||||
|
||||
async setup (props, { attrs }) {
|
||||
const query = parseQuery(parseURL(url).search)
|
||||
const query = parseQuery(new URL(url, 'http://localhost').search)
|
||||
const urlProps = query.props ? destr<Record<string, any>>(query.props as string) : {}
|
||||
const path = resolve(query.path as string)
|
||||
if (!path.startsWith(devRootDir)) {
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { parseURL } from 'ufo'
|
||||
import { defineNuxtPlugin } from '../nuxt'
|
||||
import { loadPayload } from '../composables/payload'
|
||||
import { onNuxtReady } from '../composables/ready'
|
||||
@ -24,7 +23,8 @@ export default defineNuxtPlugin({
|
||||
onNuxtReady(() => {
|
||||
// Load payload into cache
|
||||
nuxtApp.hooks.hook('link:prefetch', async (url) => {
|
||||
if (!parseURL(url).protocol) {
|
||||
const { protocol } = new URL(url, window.location.href)
|
||||
if (!protocol) {
|
||||
await loadPayload(url)
|
||||
}
|
||||
})
|
||||
|
@ -1,6 +1,6 @@
|
||||
import type { Ref } from 'vue'
|
||||
import { computed, defineComponent, h, isReadonly, reactive } from 'vue'
|
||||
import { isEqual, joinURL, parseQuery, parseURL, stringifyParsedURL, stringifyQuery, withoutBase } from 'ufo'
|
||||
import { isEqual, joinURL, parseQuery, stringifyParsedURL, stringifyQuery, withoutBase } from 'ufo'
|
||||
import { createError } from 'h3'
|
||||
import { defineNuxtPlugin, useRuntimeConfig } from '../nuxt'
|
||||
import { getRouteRules } from '../composables/manifest'
|
||||
@ -45,7 +45,7 @@ function getRouteFromPath (fullPath: string | Partial<Route>) {
|
||||
})
|
||||
}
|
||||
|
||||
const url = parseURL(fullPath.toString())
|
||||
const url = new URL(fullPath.toString(), import.meta.client ? window.location.href : 'http://localhost')
|
||||
return {
|
||||
path: url.pathname,
|
||||
fullPath,
|
||||
|
Loading…
Reference in New Issue
Block a user