(value: any, key: string)
| 145 | ] |
| 146 | |
| 147 | function sanitizeValue(value: any, key: string): any { |
| 148 | const lowerKey = key.toLowerCase() |
| 149 | const isSensitive = sensitiveFields.some((field) => lowerKey.includes(field)) |
| 150 | |
| 151 | if (isSensitive) { |
| 152 | return '********' |
| 153 | } |
| 154 | |
| 155 | if (value && typeof value === 'object' && !Array.isArray(value)) { |
| 156 | return sanitizeObject(value) |
| 157 | } |
| 158 | |
| 159 | if (Array.isArray(value)) { |
| 160 | return value.map((item, index) => sanitizeValue(item, `${key}[${index}]`)) |
| 161 | } |
| 162 | |
| 163 | return value |
| 164 | } |
| 165 | |
| 166 | function sanitizeObject(obj: Record<string, any>): Record<string, any> { |
| 167 | const result: Record<string, any> = {} |
no test coverage detected