davidmarkclements / fast-redact

very fast object redaction
MIT License
278 stars 30 forks source link

Fixed: Error is thrown for wildcard paths vs object with nested nulls #47

Closed kostya-luxuryescape closed 2 years ago

kostya-luxuryescape commented 2 years ago

As per title the following error was thrown when I was using path with multiple wildcards against an object with nulls

TypeError: Cannot use 'in' operator to search for 'x' in null
at specialSet (/workspace/lib-logger/node_modules/fast-redact/lib/modifiers.js:120:53)
at nestedRedact (/workspace/lib-logger/node_modules/fast-redact/lib/modifiers.js:73:7)
   const redact = fastRedact({
      paths: ['*.*.x'],
      serialize: false,
      censor: "[REDACTED]",
    });

    expect(redact({a: {b: null}})).toEqual({a: {b: null}});