Skip to content
Source
Sign inSign up
TanStack/router

refactor(router-core): redirect skips creating a URL object if href is not a string #4986

MergedSheraff(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/4986/headmerged by Sheraff(GitHub profile, opens in a new tab)

Showing 1 changed file with 3 additions and 3 deletions.

x
0 of 1 viewed, 1 left
3 additions and 3 deletionspackages/router-core/src/redirect.tsModified
View file
@@ -65,9 +65,9 @@
): Redirect<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> {
opts.statusCode = opts.statusCode || opts.code || 307
​
- if (!opts.reloadDocument) {
+ if (!opts.reloadDocument && typeof opts.href === 'string') {
try {
- new URL(`${opts.href}`)
+ new URL(opts.href)
opts.reloadDocument = true
} catch {}
@@ -103,7 +103,7 @@
​
export function parseRedirect(obj: any) {
- if (typeof obj === 'object' && obj.isSerializedRedirect) {
+ if (obj !== null && typeof obj === 'object' && obj.isSerializedRedirect) {
return redirect(obj)
​