File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,15 @@ function isObjectEqual (a = {}, b = {}): boolean {
7979 if ( aKeys . length !== bKeys . length ) {
8080 return false
8181 }
82- return aKeys . every ( key => String ( a [ key ] ) === String ( b [ key ] ) )
82+ return aKeys . every ( key => {
83+ const aVal = a [ key ]
84+ const bVal = b [ key ]
85+ // check nested equality
86+ if ( typeof aVal === 'object' && typeof bVal === 'object' ) {
87+ return isObjectEqual ( aVal , bVal )
88+ }
89+ return String ( aVal ) === String ( bVal )
90+ } )
8391}
8492
8593export function isIncludedRoute ( current : Route , target : Route ) : boolean {
Original file line number Diff line number Diff line change @@ -30,6 +30,23 @@ describe('Route utils', () => {
3030 }
3131 expect ( isSameRoute ( a , b ) ) . toBe ( true )
3232 } )
33+
34+ it ( 'nested query' , ( ) => {
35+ const a = {
36+ path : '/abc' ,
37+ query : { foo : { bar : 'bar' } , arr : [ 1 , 2 ] }
38+ }
39+ const b = {
40+ path : '/abc' ,
41+ query : { arr : [ 1 , 2 ] , foo : { bar : 'bar' } }
42+ }
43+ const c = {
44+ path : '/abc' ,
45+ query : { arr : [ 1 , 2 ] , foo : { bar : 'not bar' } }
46+ }
47+ expect ( isSameRoute ( a , b ) ) . toBe ( true )
48+ expect ( isSameRoute ( a , c ) ) . toBe ( false )
49+ } )
3350 } )
3451
3552 describe ( 'isIncludedRoute' , ( ) => {
You can’t perform that action at this time.
0 commit comments