Skip to content

Commit

Permalink
Fixed: Error is thrown for wildcard paths against object with nested …
Browse files Browse the repository at this point in the history
…null values (#47)
  • Loading branch information
kostya-luxuryescape authored Feb 23, 2022
1 parent 4e7d7d3 commit ab8f7cb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/modifiers.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function specialSet (o, k, path, afterPath, censor, isCensorFct, censorFctTakesP
const wck = wcKeys[j]
const wcov = n[wck]
const kIsWc = k === '*'
if (kIsWc || (typeof wcov === 'object' && k in wcov)) {
if (kIsWc || (typeof wcov === 'object' && wcov !== null && k in wcov)) {
if (kIsWc) {
ov = wcov
} else {
Expand Down
11 changes: 11 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1237,3 +1237,14 @@ test('handles multi wildcards within arrays with undefined values', ({ end, is }
is(redact(o), '{"a":[{"x":{"d":[{"i":"[REDACTED]","j":"NR"}]}}]}')
end()
})

test('handles multi wildcards with objects containing nulls', ({ end, is }) => {
const redact = fastRedact({
paths: ['*.*.x'],
serialize: false,
censor: '[REDACTED]'
})
const o = { a: { b: null } }
is(redact(o), o)
end()
})

0 comments on commit ab8f7cb

Please sign in to comment.