diff --git a/packages/next/next-server/lib/router/router.ts b/packages/next/next-server/lib/router/router.ts index 933e84e29eeb5adbd9721e94935fb93285060e9b..83caa11e55278f1ad7b0210f2ff4c87b5dc3f5c5 100644 --- a/packages/next/next-server/lib/router/router.ts +++ b/packages/next/next-server/lib/router/router.ts @@ -240,8 +240,8 @@ export default class Router implements BaseRouter { if ( e.state && this.isSsr && - e.state.url === this.pathname && - e.state.as === this.asPath + e.state.as === this.asPath && + parse(e.state.url).pathname === this.pathname ) { return } diff --git a/test/integration/production/test/index.test.js b/test/integration/production/test/index.test.js index e66fa416a6a5832b05dfd48afac31082f1e11ac3..714d16dcde8011ec47b8e393c7f576425fe4d9ea 100644 --- a/test/integration/production/test/index.test.js +++ b/test/integration/production/test/index.test.js @@ -310,6 +310,23 @@ describe('Production Usage', () => { expect(newText).toBe('server') }) + it('should navigate to external site and back (with query)', async () => { + const browser = await webdriver(appPort, '/external-and-back?hello=world') + const initialText = await browser.elementByCss('p').text() + expect(initialText).toBe('server') + + await browser + .elementByCss('a') + .click() + .waitForElementByCss('input') + .back() + .waitForElementByCss('p') + + await waitFor(1000) + const newText = await browser.elementByCss('p').text() + expect(newText).toBe('server') + }) + it('should change query correctly', async () => { const browser = await webdriver(appPort, '/query?id=0') let id = await browser.elementByCss('#q0').text()