fast-redact
Advanced tools
Comparing version 3.4.1 to 3.5.0
@@ -11,3 +11,3 @@ 'use strict' | ||
function groupRestore ({ keys, values, target }) { | ||
if (target == null) return | ||
if (target == null || typeof target === 'string') return | ||
const length = keys.length | ||
@@ -22,3 +22,3 @@ for (var i = 0; i < length; i++) { | ||
const target = get(o, path) | ||
if (target == null) return { keys: null, values: null, target: null, flat: true } | ||
if (target == null || typeof target === 'string') return { keys: null, values: null, target, flat: true } | ||
const keys = Object.keys(target) | ||
@@ -25,0 +25,0 @@ const keysLength = keys.length |
{ | ||
"name": "fast-redact", | ||
"version": "3.4.1", | ||
"version": "3.5.0", | ||
"description": "very fast object redaction", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -92,2 +92,31 @@ 'use strict' | ||
test('returns original value when passed non-object at wildcard key', ({ end, doesNotThrow, strictSame }) => { | ||
const redactSerializeFalse = fastRedact({ | ||
paths: ['a.*'], | ||
strict: false, | ||
serialize: false | ||
}) | ||
const primitives = [null, undefined, 'A', 1, false] | ||
primitives.forEach((a) => { | ||
doesNotThrow(() => redactSerializeFalse({ a })) | ||
const res = redactSerializeFalse({ a }) | ||
strictSame(res, { a }) | ||
}) | ||
end() | ||
}) | ||
test('returns censored values when passed array at wildcard key', ({ end, strictSame }) => { | ||
const redactSerializeFalse = fastRedact({ | ||
paths: ['a.*'], | ||
strict: false, | ||
serialize: false | ||
}) | ||
const res = redactSerializeFalse({ a: ['redact', 'me'] }) | ||
strictSame(res.a, [censor, censor]) | ||
end() | ||
}) | ||
test('throws if a path is not a string', ({ end, throws }) => { | ||
@@ -94,0 +123,0 @@ const invalidTypeMsg = 'fast-redact - Paths must be (non-empty) strings' |
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
92665
2244