mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
fix(nuxt): use router.resolve
to resolve initial url (#4770)
This commit is contained in:
parent
686bd84d58
commit
f74a523f13
@ -185,7 +185,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|||||||
nuxtApp.hooks.hookOnce('app:created', async () => {
|
nuxtApp.hooks.hookOnce('app:created', async () => {
|
||||||
try {
|
try {
|
||||||
await router.replace({
|
await router.replace({
|
||||||
path: initialURL,
|
...router.resolve(initialURL),
|
||||||
force: true
|
force: true
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -59,6 +59,18 @@ describe('pages', () => {
|
|||||||
await expectNoClientErrors('/not-found')
|
await expectNoClientErrors('/not-found')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('preserves query', async () => {
|
||||||
|
const html = await $fetch('/?test=true')
|
||||||
|
|
||||||
|
// Snapshot
|
||||||
|
// expect(html).toMatchInlineSnapshot()
|
||||||
|
|
||||||
|
// should render text
|
||||||
|
expect(html).toContain('Path: /?test=true')
|
||||||
|
|
||||||
|
await expectNoClientErrors('/?test=true')
|
||||||
|
})
|
||||||
|
|
||||||
it('/nested/[foo]/[bar].vue', async () => {
|
it('/nested/[foo]/[bar].vue', async () => {
|
||||||
const html = await $fetch('/nested/one/two')
|
const html = await $fetch('/nested/one/two')
|
||||||
|
|
||||||
|
1
test/fixtures/basic/pages/index.vue
vendored
1
test/fixtures/basic/pages/index.vue
vendored
@ -7,6 +7,7 @@
|
|||||||
<div>RuntimeConfig | testConfig: {{ config.testConfig }}</div>
|
<div>RuntimeConfig | testConfig: {{ config.testConfig }}</div>
|
||||||
<div>Composable | foo: {{ foo }}</div>
|
<div>Composable | foo: {{ foo }}</div>
|
||||||
<div>Composable | bar: {{ bar }}</div>
|
<div>Composable | bar: {{ bar }}</div>
|
||||||
|
<div>Path: {{ $route.fullPath }}</div>
|
||||||
<NuxtLink to="/">
|
<NuxtLink to="/">
|
||||||
Link
|
Link
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
|
Loading…
Reference in New Issue
Block a user