Closed juanjoDiaz closed 4 years ago
I actually tested this in our codebase and can confirm that it fixes #494, thanks a lot for the great work @juanjoDiaz !
Released as v5.0.4
Thanks a lot @juanjoDiaz and @knownasilya you are awesome! 👍
@juanjoDiaz I'm not sure if this is intended behavior or not, I just noticed the new introduced code modifies the objects directly, we are using TypeScript and our data is marked as readonly
, which is why we noticed this part of the code:
if (pathArray.length === 1) {
delete obj[key];
return obj;
}
The operation delete obj[key];
seems to delete this on the original object as well. You can reproduce this by making a copy of the data that you pass into parse
in a test before running parse
, then after running parse
, compare the copy with the object that was passed in. Then you will see that the empty array has been removed from the original data as well in a case like it was described in the issue.
Dammit! Sometimes too fast is not too good...
This highlights that we should really move to typescript and avoid this type of thing...
Fixes #494 in v5