Merge pull request #1795 from Wevah/ios-candidate
Fix sites being added to the no-favicons cache if the homepage fails to load
This commit is contained in:
commit
e22489ce40
|
@ -136,6 +136,7 @@ final class FaviconDownloader {
|
||||||
|
|
||||||
findFaviconURLs(with: url) { (faviconURLs) in
|
findFaviconURLs(with: url) { (faviconURLs) in
|
||||||
if let faviconURLs = faviconURLs {
|
if let faviconURLs = faviconURLs {
|
||||||
|
// If the site explicitly specifies favicon.ico, it will appear twice.
|
||||||
self.currentHomePageHasOnlyFaviconICO = faviconURLs.count == 1
|
self.currentHomePageHasOnlyFaviconICO = faviconURLs.count == 1
|
||||||
|
|
||||||
if let firstIconURL = faviconURLs.first {
|
if let firstIconURL = faviconURLs.first {
|
||||||
|
@ -177,11 +178,9 @@ final class FaviconDownloader {
|
||||||
|
|
||||||
remainingFaviconURLs[homePageURL] = nil
|
remainingFaviconURLs[homePageURL] = nil
|
||||||
|
|
||||||
if let url = singleFaviconDownloader.homePageURL {
|
if self.homePageToFaviconURLCache[homePageURL] == nil {
|
||||||
if self.homePageToFaviconURLCache[url] == nil {
|
self.homePageToFaviconURLCache[homePageURL] = singleFaviconDownloader.faviconURL
|
||||||
self.homePageToFaviconURLCache[url] = singleFaviconDownloader.faviconURL
|
self.homePageToFaviconURLCacheDirty = true
|
||||||
self.homePageToFaviconURLCacheDirty = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
postFaviconDidBecomeAvailableNotification(singleFaviconDownloader.faviconURL)
|
postFaviconDidBecomeAvailableNotification(singleFaviconDownloader.faviconURL)
|
||||||
|
@ -212,21 +211,22 @@ private extension FaviconDownloader {
|
||||||
}
|
}
|
||||||
|
|
||||||
FaviconURLFinder.findFaviconURLs(with: homePageURL) { (faviconURLs) in
|
FaviconURLFinder.findFaviconURLs(with: homePageURL) { (faviconURLs) in
|
||||||
|
guard var faviconURLs = faviconURLs else {
|
||||||
|
completion(nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var defaultFaviconURL: String? = nil
|
var defaultFaviconURL: String? = nil
|
||||||
|
|
||||||
if let scheme = url.scheme, let host = url.host {
|
if let scheme = url.scheme, let host = url.host {
|
||||||
defaultFaviconURL = "\(scheme)://\(host)/favicon.ico".lowercased(with: FaviconDownloader.localeForLowercasing)
|
defaultFaviconURL = "\(scheme)://\(host)/favicon.ico".lowercased(with: FaviconDownloader.localeForLowercasing)
|
||||||
}
|
}
|
||||||
|
|
||||||
if var faviconURLs = faviconURLs {
|
if let defaultFaviconURL = defaultFaviconURL {
|
||||||
if let defaultFaviconURL = defaultFaviconURL {
|
faviconURLs.append(defaultFaviconURL)
|
||||||
faviconURLs.append(defaultFaviconURL)
|
|
||||||
}
|
|
||||||
completion(faviconURLs)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
completion(defaultFaviconURL != nil ? [defaultFaviconURL!] : nil)
|
completion(faviconURLs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue