Skip to content

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

@hermawan-hadi

Description

@hermawan-hadi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions