Skip to content

Commit

Permalink
Fixed pathname check in router (#10547)
Browse files Browse the repository at this point in the history
* Fixed pathname check in router

Remove the query portion of the URL when checking paths

* Updated change and added trial test

* Update test

Co-authored-by: JJ Kasper <jj@jjsweb.site>
  • Loading branch information
dijs and ijjk committed Feb 19, 2020
1 parent 893fb6e commit 103e822
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/next/next-server/lib/router/router.ts
Expand Up @@ -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
}
Expand Down
17 changes: 17 additions & 0 deletions test/integration/production/test/index.test.js
Expand Up @@ -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()
Expand Down

0 comments on commit 103e822

Please sign in to comment.