Skip to content

Commit 0093cc7

Browse files
authored
fix(minimal/dev): rscPath encoding in willBeHandled (#1216)
- [x] add a failing test - [x] fix it
1 parent 46a5e1f commit 0093cc7

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
'use client';
2+
23
import { useState } from 'react';
4+
import { useRefetch } from 'waku/minimal/client';
5+
36
import { ClientBox } from './Box.js';
47

58
export const ClientCounter = () => {
69
const [count, setCount] = useState(0);
10+
const refetch = useRefetch();
711
return (
812
<ClientBox data-testid="client-counter">
913
<p data-testid="count">{count}</p>
1014
<button data-testid="increment" onClick={() => setCount((c) => c + 1)}>
1115
Increment
1216
</button>
17+
<button data-testid="refetch1" onClick={() => refetch('foo')}>
18+
Refetch1
19+
</button>
20+
<button data-testid="refetch2" onClick={() => refetch('[bar]')}>
21+
Refetch2
22+
</button>
23+
<button data-testid="refetch3" onClick={() => refetch('baz/qux')}>
24+
Refetch3
25+
</button>
1326
</ClientBox>
1427
);
1528
};

e2e/rsc-basic.spec.ts

+10
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ for (const mode of ['DEV', 'PRD'] as const) {
4949
).toHaveText('2');
5050
});
5151

52+
test('refetch', async ({ page }) => {
53+
await page.goto(`http://localhost:${port}/`);
54+
await page.getByTestId('refetch1').click();
55+
await expect(page.getByTestId('app-name')).toHaveText('foo');
56+
await page.getByTestId('refetch2').click();
57+
await expect(page.getByTestId('app-name')).toHaveText('[bar]');
58+
await page.getByTestId('refetch3').click();
59+
await expect(page.getByTestId('app-name')).toHaveText('baz/qux');
60+
});
61+
5262
test('server action', async ({ page }) => {
5363
await page.goto(`http://localhost:${port}/`);
5464
await expect(page.getByTestId('app-name')).toHaveText('Waku');

examples/22_define-router/src/components/HomeLayout.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ const HomeLayout = ({ children }: { children: ReactNode }) => (
5151
<li>
5252
<Link to="/dynamic/bar">Dynamic / bar</Link>
5353
</li>
54+
<li>
55+
<Link to="/dynamic/[aaa]">Dynamic / [aaa]</Link>
56+
</li>
5457
</ul>
5558
{children}
5659
</div>

packages/waku/src/lib/middleware/dev-server-impl.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ const createMainViteServer = (
214214
const vite = await vitePromise;
215215
try {
216216
const result = await vite.transformRequest(pathname);
217-
if (result?.code === `export default "/@fs${pathname}"`) {
217+
if (result?.code === `export default "/@fs${encodeURI(pathname)}"`) {
218218
return false;
219219
}
220220
return !!result;

0 commit comments

Comments
 (0)