Use a single compactMap() instead of filter().compactMap()
This commit is contained in:
parent
4ac8107f27
commit
2ac4df4ee6
|
@ -49,20 +49,20 @@ struct FaviconURLFinder {
|
||||||
|
|
||||||
// If the favicon has an explicit type, check that for an ignored type; otherwise, check the file extension.
|
// If the favicon has an explicit type, check that for an ignored type; otherwise, check the file extension.
|
||||||
HTMLMetadataDownloader.downloadMetadata(for: homePageURL) { (htmlMetadata) in
|
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 let type = favicon.type {
|
||||||
if ignoredMimeTypes.contains(type) {
|
if ignoredMimeTypes.contains(type) {
|
||||||
return false
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if let urlString = favicon.urlString, let url = URL(string: urlString), ignoredExtensions.contains(url.pathExtension) {
|
if let urlString = favicon.urlString, let url = URL(string: urlString), ignoredExtensions.contains(url.pathExtension) {
|
||||||
return false
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return favicon.urlString
|
||||||
}).compactMap { $0.urlString }
|
})
|
||||||
|
|
||||||
completion(faviconURLs)
|
completion(faviconURLs)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue