Call the completion handler with nil if faviconURLs is nil

Fixes #1791.
This commit is contained in:
Nate Weaver 2020-02-15 08:53:56 -06:00
parent b3f736f899
commit aad1fc4a0c
1 changed files with 8 additions and 7 deletions

View File

@ -211,21 +211,22 @@ private extension FaviconDownloader {
}
FaviconURLFinder.findFaviconURLs(with: homePageURL) { (faviconURLs) in
guard var faviconURLs = faviconURLs else {
completion(nil)
return
}
var defaultFaviconURL: String? = nil
if let scheme = url.scheme, let host = url.host {
defaultFaviconURL = "\(scheme)://\(host)/favicon.ico".lowercased(with: FaviconDownloader.localeForLowercasing)
}
if var faviconURLs = faviconURLs {
if let defaultFaviconURL = defaultFaviconURL {
faviconURLs.append(defaultFaviconURL)
}
completion(faviconURLs)
return
}
completion(defaultFaviconURL != nil ? [defaultFaviconURL!] : nil)
completion(faviconURLs)
}
}