Skip to content

Commit

Permalink
Fix optional wrapping issue in mapToStrings function by explicitedly …
Browse files Browse the repository at this point in the history
…allowing Any? values then unwrapping them.
  • Loading branch information
didiergarcia committed Dec 20, 2023
1 parent fd06a43 commit f2e2df0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Sources/SegmentFirebase/FirebaseDestination.swift
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,15 @@ extension FirebaseDestination {
}

// Makes sure all traits are string based for Firebase API
func mapToStrings(_ mapDictionary: [String: Any], finalize: (String, String) -> Void) {
func mapToStrings(_ mapDictionary: [String: Any?], finalize: (String, String) -> Void) {

for (key, data) in mapDictionary {
var dataString = data as? String ?? "\(data)"
let keyString = key.replacingOccurrences(of: " ", with: "_")
dataString = dataString.trimmingCharacters(in: .whitespacesAndNewlines)
finalize(keyString, dataString)
if let d = data {
var dataString = d as? String ?? "\(d)"
let keyString = key.replacingOccurrences(of: " ", with: "_")
dataString = dataString.trimmingCharacters(in: .whitespacesAndNewlines)
finalize(keyString, dataString)
}
}
}
}
Expand Down

0 comments on commit f2e2df0

Please sign in to comment.