Skip to content

Commit 4490a45

Browse files
committed
fix: Backslash incorrectly decoded (#3962)
1 parent de16769 commit 4490a45

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

packages/router-core/src/path.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,7 @@ function baseParsePathname(
348348
// Handle regular pathname segment
349349
return {
350350
type: SEGMENT_TYPE_PATHNAME,
351-
value: partToMatch.includes('%25')
352-
? partToMatch
353-
.split('%25')
354-
.map((segment) => decodeURI(segment))
355-
.join('%25')
356-
: decodeURI(partToMatch),
351+
value: partToMatch,
357352
}
358353
}),
359354
)

packages/router-core/tests/path.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,12 @@ describe('interpolatePath', () => {
345345
params: { _splat: 'sean/cassiere' },
346346
result: '/users/sean/cassiere',
347347
},
348+
{
349+
name: 'should preserve backslashes in path parameters',
350+
path: '/b/$postId',
351+
params: { postId: 'test[s\\%2F.\\%2Fparameter]' },
352+
result: '/b/test%5Bs%5C%252F.%5C%252Fparameter%5D',
353+
},
348354
])('$name', ({ path, params, decodeCharMap, result }) => {
349355
expect(
350356
interpolatePath({

0 commit comments

Comments
 (0)