Skip to content

Commit

Permalink
fix(url): handle array comparison and proxied arrays properly (#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Mar 6, 2024
1 parent 5031ebd commit 2f3842f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/composables/Url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function useUrlQuerySync(
const newQuery: Record<string, any> = {}

for (const key in flattenedState) {
if (!exclude.includes(key) && flattenedDefaultState[key] !== flattenedState[key]) {
if (!exclude.includes(key) && !isEqual(flattenedState[key], flattenedDefaultState[key])) {
newQuery[key] = flattenedState[key]
}
}
Expand Down Expand Up @@ -94,7 +94,9 @@ function flattenObject(obj: Record<string, any>, path: string[] = []): Record<st
for (const key in obj) {
const value = obj[key]

if (value && typeof value === 'object' && !Array.isArray(value)) {
if (Array.isArray(value)) {
result[path.concat(key).join('.')] = value.slice()
} else if (value && typeof value === 'object') {
Object.assign(result, flattenObject(value, [...path, key]))
} else {
result[path.concat(key).join('.')] = value
Expand Down

0 comments on commit 2f3842f

Please sign in to comment.