Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Commit

Permalink
Made the code safer by removing the force cast and modified the heade…
Browse files Browse the repository at this point in the history
…r dictonary building to use reduce(into:) so that the overall code is more idionatic Swift
  • Loading branch information
raphaelcruzeiro committed Oct 8, 2020
1 parent 9eada43 commit 87c1e33
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Sources/Bugsnag/BugsnagReporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,14 @@ extension BugsnagReporter {
eventRequestBody = nil
}

var headerDict: [String : Any] = request.headers.reduce([:], { result, value in
var copy = result
copy[value.0] = value.1
return copy
})
var headerDict: [String : Any] = request.headers.reduce(into: [:]) { result, value in
result[value.0] = value.1
}
strip(keys: configuration.keyFilters, from: &headerDict)

let filteredHeaders: [(String, String)] = headerDict.map {
k, v in (k, v as! String)
let filteredHeaders: [(String, String)] = headerDict.compactMap { k, v in
guard let value = v as? String else { return nil }
return (k, value)
}

eventRequest = .init(
Expand Down

0 comments on commit 87c1e33

Please sign in to comment.