Use a single compactMap() instead of filter().compactMap()

This commit is contained in:
Nate Weaver 2020-02-08 17:46:48 -06:00
parent 4ac8107f27
commit 2ac4df4ee6
1 changed files with 5 additions and 5 deletions

View File

@ -49,20 +49,20 @@ struct FaviconURLFinder {
// If the favicon has an explicit type, check that for an ignored type; otherwise, check the file extension.
HTMLMetadataDownloader.downloadMetadata(for: homePageURL) { (htmlMetadata) in
let faviconURLs = htmlMetadata?.favicons.filter({ (favicon) -> Bool in
let faviconURLs = htmlMetadata?.favicons.compactMap({ (favicon) -> String? in
if let type = favicon.type {
if ignoredMimeTypes.contains(type) {
return false
return nil
}
}
else {
if let urlString = favicon.urlString, let url = URL(string: urlString), ignoredExtensions.contains(url.pathExtension) {
return false
return nil
}
}
return true
}).compactMap { $0.urlString }
return favicon.urlString
})
completion(faviconURLs)
}