Skip to content
Source
Sign inSign up
TanStack/router

fix(router-core): compare SSR redirect hrefs in the same search encoding #8848

Openpavstev(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/8848/headopened

Showing 6 changed files with 15 additions and 7 deletions (loading 3).

x
0 of 6 viewed, 6 left
5 additions and 0 deletions.changeset/quiet-commas-agree.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/router-core': patch
+---
+​
+Fix an infinite SSR redirect loop when a custom search serializer writes characters such as `,` or `%20` that the server normalizes before the router sees the request.
2 additions and 6 deletionspackages/router-core/src/ssr/ssr-server.tsModified
View file
@@ -5,7 +5,7 @@
createInlineCssStyleAsset,
getStylesheetHref,
} from '../manifest'
-import { decodePath } from '../utils'
+import { decodePath, normalizeSearchEncoding } from '../utils'
import { createSieveCache } from '../sieve-cache'
import { rootRouteId } from '../root'
import { _getRenderedMatches } from '../load-client'
@@ -685,12 +685,8 @@
? rawUrl.pathname.replace(/^\/+/, '/')
: rawUrl.pathname,
- const searchParams = new URLSearchParams(rawUrl.search)
const normalizedHref =
- decodedPathname +
- (searchParams.size > 0 ? '?' : '') +
- searchParams.toString() +
- rawUrl.hash
+ decodedPathname + normalizeSearchEncoding(rawUrl.search) + rawUrl.hash
​