Skip to content

Commit 1b2e079

Browse files
author
dave
authored
fix development mode bug with pages with "+" and other special characters (#28122)
* add encodeURIComponent so certain characters don't bug out (fixes #22099) * add integration test for pr #28122
1 parent 5d4d880 commit 1b2e079

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

packages/next/client/dev/on-demand-entries-utils.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ export function setupPing(assetPrefix, pathnameFn, retry) {
1919
closePing()
2020

2121
evtSource = getEventSourceWrapper({
22-
path: `${assetPrefix}/_next/webpack-hmr?page=${currentPage}`,
22+
path: `${assetPrefix}/_next/webpack-hmr?page=${encodeURIComponent(
23+
currentPage
24+
)}`,
2325
timeout: 5000,
2426
})
2527

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export default function Page() {
2+
return (
3+
<>
4+
if this page reloads during development mode, then the browser did not
5+
connect to the on demand entries handler. see on-demand-entry-handler.ts
6+
and on-demand-entries-utils.js
7+
</>
8+
)
9+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* eslint-env jest */
2+
3+
import { join } from 'path'
4+
import webdriver from 'next-webdriver'
5+
import { findPort, launchApp, killApp, waitFor } from 'next-test-utils'
6+
7+
jest.setTimeout(1000 * 60 * 2)
8+
9+
const appDir = join(__dirname, '../')
10+
11+
let app
12+
let appPort
13+
14+
beforeAll(async () => {
15+
appPort = await findPort()
16+
app = await launchApp(appDir, appPort)
17+
})
18+
19+
// see issue #22099
20+
it('page should not reload when the file is not changed', async () => {
21+
const browser = await webdriver(appPort, '/with+Special&Chars=')
22+
23+
browser.eval(`window.doesNotReloadCheck = true`)
24+
25+
await waitFor(10000)
26+
27+
expect(await browser.eval('window.doesNotReloadCheck')).toBe(true)
28+
})
29+
30+
afterAll(() => killApp(app))

0 commit comments

Comments
 (0)