diff --git a/e2e/docs/router/navigation.md b/e2e/docs/router/navigation.md new file mode 100644 index 0000000000..2df4da53cb --- /dev/null +++ b/e2e/docs/router/navigation.md @@ -0,0 +1,16 @@ + + + + diff --git a/e2e/tests/router/navigation.cy.ts b/e2e/tests/router/navigation.cy.ts new file mode 100644 index 0000000000..a874b69d49 --- /dev/null +++ b/e2e/tests/router/navigation.cy.ts @@ -0,0 +1,21 @@ +it('should preserve query', () => { + const E2E_BASE = Cypress.env('E2E_BASE') + + cy.visit('/router/navigation.html') + + cy.get('#home').click() + + cy.location('pathname').should('eq', E2E_BASE) + cy.location('search').should('eq', '?home=true') +}) + +it('should preserve hash', () => { + const E2E_BASE = Cypress.env('E2E_BASE') + + cy.visit('/router/navigation.html') + + cy.get('#404').click() + + cy.location('pathname').should('eq', `${E2E_BASE}404.html`) + cy.location('hash').should('eq', '#404') +}) diff --git a/packages/client/src/router/createVueRouter.ts b/packages/client/src/router/createVueRouter.ts index d12be64782..a9dd605096 100644 --- a/packages/client/src/router/createVueRouter.ts +++ b/packages/client/src/router/createVueRouter.ts @@ -40,9 +40,9 @@ export const createVueRouter = (): Router => { // and save page data to route meta router.beforeResolve(async (to, from): Promise => { if (to.path !== from.path || from === START_LOCATION) { - const route = resolveRoute(to.path) + const route = resolveRoute(to.fullPath) - if (route.path !== to.path) { + if (route.path !== to.fullPath) { return route.path } const pageChunk = await route.loader()