Skip to content

Commit a7df734

Browse files
committed
fix: move deletion inside the loop
1 parent f9d631f commit a7df734

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

plugin/server/src/utils/clean-data.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,10 @@ export function cleanData<
8282
resultData[attr] = mediaFiles.id
8383
}
8484
}
85-
})
8685

87-
// Remove empty arrays after all processing
88-
Object.keys(resultData).forEach((key) => {
89-
if (Array.isArray(resultData[key]) && resultData[key].length === 0) {
90-
delete resultData[key]
86+
// Remove attribute if it's an empty array
87+
if (Array.isArray(resultData[attr]) && resultData[attr].length === 0) {
88+
delete resultData[attr]
9189
}
9290
})
9391

0 commit comments

Comments
 (0)