(value: unknown, fields: ReadonlySet<string>)
| 83 | const normalizeField = (field: string) => field.replace(/[^a-z0-9]/gi, "").toLowerCase() |
| 84 | |
| 85 | const redactJsonFields = (value: unknown, fields: ReadonlySet<string>): unknown => { |
| 86 | if (Array.isArray(value)) return value.map((item) => redactJsonFields(item, fields)) |
| 87 | if (!value || typeof value !== "object") return value |
| 88 | return Object.fromEntries( |
| 89 | Object.entries(value).map(([key, child]) => [ |
| 90 | key, |
| 91 | fields.has(normalizeField(key)) ? REDACTED : redactJsonFields(child, fields), |
| 92 | ]), |
| 93 | ) |
| 94 | } |
| 95 | |
| 96 | const redactBody = (value: string, fields: ReadonlySet<string>, transform: ((body: string) => string) | undefined) => { |
| 97 | const redacted = Option.match(decodeJson(value), { |
no test coverage detected