Skip to content

Commit 2c29488

Browse files
committed
test(router-core): cover legacy null-byte decode in hydrateSsrMatchId
The codec keeps the U+0000 -> "/" decode branch so SSR payloads from a deploy before the U+FFFD switch still hydrate. That branch was the one path the suite didn't exercise, so add a test for it.
1 parent e83ef26 commit 2c29488

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

packages/router-core/tests/ssr-match-id.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ describe('ssr match id codec', () => {
2424
expect(hydrateSsrMatchId('\uFFFDposts\uFFFD1')).toBe('/posts/1')
2525
})
2626

27+
it('still decodes legacy null-byte delimiters for backward compatibility', () => {
28+
// Payloads emitted before the switch to U+FFFD encoded slashes as U+0000.
29+
// hydrateSsrMatchId keeps the legacy decode branch so an in-flight payload
30+
// from a previous deploy still hydrates correctly.
31+
const nullChar = String.fromCharCode(0)
32+
expect(hydrateSsrMatchId(`${nullChar}posts${nullChar}1`)).toBe('/posts/1')
33+
})
34+
2735
it('does not emit control characters that are invalid in SSR HTML', () => {
2836
const dehydratedId = dehydrateSsrMatchId(
2937
'/$orgId/projects/$projectId//acme/projects/dashboard/{}',

0 commit comments

Comments
 (0)