File tree 2 files changed +26
-1
lines changed
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 {
79
79
if ( aKeys . length !== bKeys . length ) {
80
80
return false
81
81
}
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
+ } )
83
91
}
84
92
85
93
export function isIncludedRoute ( current : Route , target : Route ) : boolean {
Original file line number Diff line number Diff line change @@ -30,6 +30,23 @@ describe('Route utils', () => {
30
30
}
31
31
expect ( isSameRoute ( a , b ) ) . toBe ( true )
32
32
} )
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
+ } )
33
50
} )
34
51
35
52
describe ( 'isIncludedRoute' , ( ) => {
You can’t perform that action at this time.
0 commit comments