@@ -12,6 +12,7 @@ import {
1212 functionalUpdate ,
1313 isDangerousProtocol ,
1414 last ,
15+ nullReplaceEqualDeep ,
1516 replaceEqualDeep ,
1617} from './utils'
1718import {
@@ -1295,7 +1296,7 @@ export class RouterCore<
12951296 pathname : decodePath ( pathname ) . path ,
12961297 external : false ,
12971298 searchStr,
1298- search : replaceEqualDeep (
1299+ search : nullReplaceEqualDeep (
12991300 previousLocation ?. search ,
13001301 parsedSearch ,
13011302 ) as any ,
@@ -1324,7 +1325,10 @@ export class RouterCore<
13241325 pathname : decodePath ( url . pathname ) . path ,
13251326 external : ! ! this . rewrite && url . origin !== this . origin ,
13261327 searchStr,
1327- search : replaceEqualDeep ( previousLocation ?. search , parsedSearch ) as any ,
1328+ search : nullReplaceEqualDeep (
1329+ previousLocation ?. search ,
1330+ parsedSearch ,
1331+ ) as any ,
13281332 hash : decodePath ( url . hash . slice ( 1 ) ) . path ,
13291333 state : replaceEqualDeep ( previousLocation ?. state , state ) ,
13301334 }
@@ -1549,8 +1553,8 @@ export class RouterCore<
15491553 params : previousMatch ?. params ?? routeParams ,
15501554 _strictParams : strictParams ,
15511555 search : previousMatch
1552- ? replaceEqualDeep ( previousMatch . search , preMatchSearch )
1553- : replaceEqualDeep ( existingMatch . search , preMatchSearch ) ,
1556+ ? nullReplaceEqualDeep ( previousMatch . search , preMatchSearch )
1557+ : nullReplaceEqualDeep ( existingMatch . search , preMatchSearch ) ,
15541558 _strictSearch : strictMatchSearch ,
15551559 }
15561560 } else {
@@ -1572,7 +1576,7 @@ export class RouterCore<
15721576 pathname : interpolatedPath ,
15731577 updatedAt : Date . now ( ) ,
15741578 search : previousMatch
1575- ? replaceEqualDeep ( previousMatch . search , preMatchSearch )
1579+ ? nullReplaceEqualDeep ( previousMatch . search , preMatchSearch )
15761580 : preMatchSearch ,
15771581 _strictSearch : strictMatchSearch ,
15781582 searchError : undefined ,
@@ -1630,7 +1634,7 @@ export class RouterCore<
16301634 // Update the match's params
16311635 const previousMatch = previousMatchesByRouteId . get ( match . routeId )
16321636 match . params = previousMatch
1633- ? replaceEqualDeep ( previousMatch . params , routeParams )
1637+ ? nullReplaceEqualDeep ( previousMatch . params , routeParams )
16341638 : routeParams
16351639
16361640 if ( ! existingMatch ) {
@@ -1729,7 +1733,10 @@ export class RouterCore<
17291733 params = lastStateMatch . params
17301734 } else {
17311735 // Parse params through the route chain
1732- const strictParams : Record < string , unknown > = { ...routeParams }
1736+ const strictParams : Record < string , unknown > = Object . assign (
1737+ Object . create ( null ) ,
1738+ routeParams ,
1739+ )
17331740 for ( const route of matchedRoutes ) {
17341741 try {
17351742 extractStrictParams (
@@ -1836,7 +1843,10 @@ export class RouterCore<
18361843 // From search should always use the current location
18371844 const fromSearch = lightweightResult . search
18381845 // Same with params. It can't hurt to provide as many as possible
1839- const fromParams = { ...lightweightResult . params }
1846+ const fromParams = Object . assign (
1847+ Object . create ( null ) ,
1848+ lightweightResult . params ,
1849+ )
18401850
18411851 // Resolve the next to
18421852 // ensure this includes the basePath if set
@@ -1847,7 +1857,7 @@ export class RouterCore<
18471857 // Resolve the next params
18481858 const nextParams =
18491859 dest . params === false || dest . params === null
1850- ? { }
1860+ ? Object . create ( null )
18511861 : ( dest . params ?? true ) === true
18521862 ? fromParams
18531863 : Object . assign (
@@ -1933,7 +1943,7 @@ export class RouterCore<
19331943 } )
19341944
19351945 // Replace the equal deep
1936- nextSearch = replaceEqualDeep ( fromSearch , nextSearch )
1946+ nextSearch = nullReplaceEqualDeep ( fromSearch , nextSearch )
19371947
19381948 // Stringify the next search
19391949 const searchStr = this . options . stringifySearch ( nextSearch )
@@ -2013,7 +2023,7 @@ export class RouterCore<
20132023 let maskedNext = maskedDest ? build ( maskedDest ) : undefined
20142024
20152025 if ( ! maskedNext ) {
2016- const params = { }
2026+ const params = Object . create ( null )
20172027
20182028 if ( this . options . routeMasks ) {
20192029 const match = findFlatMatch < RouteMask < TRouteTree > > (
@@ -2032,7 +2042,7 @@ export class RouterCore<
20322042 // Otherwise, use the matched params or the provided params value
20332043 const nextParams =
20342044 maskParams === false || maskParams === null
2035- ? { }
2045+ ? Object . create ( null )
20362046 : ( maskParams ?? true ) === true
20372047 ? params
20382048 : Object . assign ( params , functionalUpdate ( maskParams , params ) )
@@ -3013,7 +3023,7 @@ export function getMatchedRoutes<TRouteLike extends RouteLike>({
30133023 routesById : Record < string , TRouteLike >
30143024 processedTree : ProcessedTree < any , any , any >
30153025} ) {
3016- const routeParams : Record < string , string > = { }
3026+ const routeParams : Record < string , string > = Object . create ( null )
30173027 const trimmedPath = trimPathRight ( pathname )
30183028
30193029 let foundRoute : TRouteLike | undefined = undefined
@@ -3022,7 +3032,7 @@ export function getMatchedRoutes<TRouteLike extends RouteLike>({
30223032 if ( match ) {
30233033 foundRoute = match . route
30243034 Object . assign ( routeParams , match . rawParams ) // Copy params, because they're cached
3025- parsedParams = Object . assign ( { } , match . parsedParams )
3035+ parsedParams = Object . assign ( Object . create ( null ) , match . parsedParams )
30263036 }
30273037
30283038 const matchedRoutes = match ?. branch || [ routesById [ rootRouteId ] ! ]
0 commit comments