Open hermawan-hadi opened 2 years ago
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.
Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.
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.
Output
Expected result of c should be retained as 1, 2, 3 respectively.