diff --git a/packages/router-core/src/path.ts b/packages/router-core/src/path.ts index 6c2e1c8e58b..f1980d8bfb1 100644 --- a/packages/router-core/src/path.ts +++ b/packages/router-core/src/path.ts @@ -348,12 +348,7 @@ function baseParsePathname( // Handle regular pathname segment return { type: SEGMENT_TYPE_PATHNAME, - value: partToMatch.includes('%25') - ? partToMatch - .split('%25') - .map((segment) => decodeURI(segment)) - .join('%25') - : decodeURI(partToMatch), + value: partToMatch, } }), ) diff --git a/packages/router-core/tests/path.test.ts b/packages/router-core/tests/path.test.ts index c84ca14fcee..94a46767618 100644 --- a/packages/router-core/tests/path.test.ts +++ b/packages/router-core/tests/path.test.ts @@ -816,6 +816,14 @@ describe('parsePathname', () => { { type: SEGMENT_TYPE_WILDCARD, value: '$' }, ], }, + { + name: 'should preserve backslashes in path parameters', + to: '/foo%5Cbar', + expected: [ + { type: SEGMENT_TYPE_PATHNAME, value: '/' }, + { type: SEGMENT_TYPE_PATHNAME, value: 'foo%5Cbar' }, + ], + }, ] satisfies ParsePathnameTestScheme)('$name', ({ to, expected }) => { const result = parsePathname(to) expect(result).toEqual(expected)