Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Value of object in nested array gets overwritten to the array last index value #52

Open
hermawan-hadi opened this issue Aug 15, 2022 · 1 comment

Comments

@hermawan-hadi
Copy link

When providing path that has nested array, value of all redacted keys in the array gets overwritten to the value of the array's last index object value.

const fastRedact = require("fast-redact");
const redact = fastRedact({
  paths: ["a[*].b[*].c"],
});

const obj = {
  a: [{ b: [{ c: 1 }, { c: 2 }, { c: 3 }] }],
};

console.log(redact(obj));
console.log(inspect(obj, undefined, null));

Output

{"a":[{"b":[{"c":"[REDACTED]"},{"c":"[REDACTED]"},{"c":"[REDACTED]"}]}]}
{
  a: [
    { b: [ { c: 3 }, { c: 3 }, { c: 3 } ] }
  ]
}

Expected result of c should be retained as 1, 2, 3 respectively.

@hermawan-hadi hermawan-hadi changed the title Value of object in nested array gets overwritten to the array last index Value of object in nested array gets overwritten to the array last index value Aug 15, 2022
@mcollina
Copy link
Collaborator

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants