File tree 1 file changed +14
-2
lines changed
Sources/Pulse/NetworkLogger
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -190,8 +190,20 @@ private extension Data {
190
190
private func _redactingSensitiveFields( _ value: Any , _ fields: Set < String > ) -> Any {
191
191
switch value {
192
192
case var object as [ String : Any ] :
193
- for key in object. keys. filter ( fields. contains) {
194
- object [ key] = " <private> "
193
+ for key in object. keys {
194
+ if fields. contains ( key) {
195
+ // Redact any value (including objects and arrays) matching the key
196
+ object [ key] = " <private> "
197
+ } else if let value = object [ key] as? [ String : Any ] {
198
+ // Recessively process values that are objects
199
+ object [ key] = _redactingSensitiveFields ( value, fields)
200
+ } else if var value = object [ key] as? [ Any ] {
201
+ // Recessively process values that are arrays
202
+ value = value. map ( { _redactingSensitiveFields ( $0, fields) } )
203
+ object [ key] = value
204
+ } else {
205
+ // All other key/values are left untouched.
206
+ }
195
207
}
196
208
return object
197
209
case let array as [ Any ] :
You can’t perform that action at this time.
0 commit comments