Skip to content

Commit d6546d9

Browse files
committed
fix(router): properly check null and undefined in isSameRoute
1 parent b952573 commit d6546d9

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/util/query.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function resolveQuery (
3838
return parsedQuery
3939
}
4040

41-
const castQueryParamValue = value => (value == null ? value : '' + value)
41+
const castQueryParamValue = value => (value == null ? value : String(value))
4242

4343
function parseQuery (query: string): Dictionary<string> {
4444
const res = {}

src/util/route.js

+2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ function isObjectEqual (a = {}, b = {}): boolean {
104104
return aKeys.every(key => {
105105
const aVal = a[key]
106106
const bVal = b[key]
107+
// query values can be null and undefined
108+
if (aVal == null || bVal == null) return aVal === bVal
107109
// check nested equality
108110
if (typeof aVal === 'object' && typeof bVal === 'object') {
109111
return isObjectEqual(aVal, bVal)

0 commit comments

Comments
 (0)