fast-redact
Advanced tools
Comparing version 1.1.11 to 1.1.12
@@ -82,3 +82,3 @@ 'use strict' | ||
nv = (i !== li) ? ov : nv | ||
n[k] = (has(n, k) && nv === ov) || typeof nv === 'undefined' ? n[k] : nv | ||
n[k] = (has(n, k) && nv === ov) || (nv === undefined && v !== undefined) ? n[k] : nv | ||
n = n[k] | ||
@@ -85,0 +85,0 @@ if (typeof n !== 'object') break |
@@ -38,3 +38,2 @@ 'use strict' | ||
} | ||
var existence = hops.map((p) => `o.${p}`).join(' && ') | ||
@@ -45,22 +44,22 @@ if (existence.length === 0) existence += `o.${path} != null` | ||
const circularDetection = ` | ||
switch (true) { | ||
${hops.reverse().map((p) => ` | ||
case o.${p} === censor: | ||
secret[${escPath}].circle = ${JSON.stringify(p)} | ||
break | ||
`).join('\n')} | ||
} | ||
` | ||
switch (true) { | ||
${hops.reverse().map((p) => ` | ||
case o.${p} === censor: | ||
secret[${escPath}].circle = ${JSON.stringify(p)} | ||
break | ||
`).join('\n')} | ||
} | ||
` | ||
return ` | ||
if (${existence}) { | ||
const val = o.${path} | ||
if (val === censor) { | ||
secret[${escPath}].precensored = true | ||
} else { | ||
secret[${escPath}].val = val | ||
o.${path} = censor | ||
${circularDetection} | ||
} | ||
if (${existence}) { | ||
const val = o.${path} | ||
if (val === censor) { | ||
secret[${escPath}].precensored = true | ||
} else { | ||
secret[${escPath}].val = val | ||
o.${path} = censor | ||
${circularDetection} | ||
} | ||
` | ||
} | ||
` | ||
}).join('\n') | ||
@@ -67,0 +66,0 @@ } |
{ | ||
"name": "fast-redact", | ||
"version": "1.1.11", | ||
"version": "1.1.12", | ||
"description": "very fast object redaction", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -710,1 +710,15 @@ 'use strict' | ||
}) | ||
test('parent wildcards – removes during serialization instead of redacting when remove option is true', ({end, is}) => { | ||
const redact = fastRedact({paths: ['a.*.c'], remove: true}) | ||
const o = {a: {b: {c: 'c'}, x: {c: 1}}} | ||
is(redact(o), `{"a":{"b":{},"x":{}}}`) | ||
end() | ||
}) | ||
test('ultimate wildcards – removes during serialization instead of redacting when remove option is true', ({end, is}) => { | ||
const redact = fastRedact({paths: ['a.b.*'], remove: true}) | ||
const o = {a: {b: {c: 'c'}, x: {c: 1}}} | ||
is(redact(o), `{"a":{"b":{},"x":{"c":1}}}`) | ||
end() | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
170266
37
1645