Skip to content

Commit 07663eb

Browse files
authored
fix(unplugin): keep hex character codes in param segments regexp (#2811)
1 parent b274c7d commit 07663eb

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎packages/router/src/unplugin/core/tree.spec.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,12 @@ describe('Tree', () => {
13451345
})
13461346
})
13471347

1348+
it('keeps hex character codes in segments with params', () => {
1349+
checkRegexp('[id][x+2E]json', '/^\\/([^/]+?)\\.json$/i', {
1350+
matcherParts: [[1, '.', 'json']],
1351+
})
1352+
})
1353+
13481354
it('works with a catch all route', () => {
13491355
checkRegexp('[...all]', '/^\\/(.*)$/i', {
13501356
matcherParts: [0],

‎packages/router/src/unplugin/core/treeNodeValue.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,9 @@ function parseFileSegment(
723723
`Invalid hex code "${buffer}" in segment "${segment}"`
724724
)
725725
}
726-
pathSegment += String.fromCharCode(parseInt(buffer, 16))
726+
const char = String.fromCharCode(parseInt(buffer, 16))
727+
pathSegment += char
728+
subSegments.push(char)
727729
}
728730
buffer = ''
729731
}

0 commit comments

Comments
 (0)