Base the homePageURL for a feed from its feed URL when looking for its favicon. When necessary only.

This commit is contained in:
Brent Simmons 2017-12-13 19:45:12 -08:00
parent 3eb95ce63d
commit b3ecf9cdba

View File

@ -47,12 +47,20 @@ final class FaviconDownloader {
return favicon(with: faviconURL) return favicon(with: faviconURL)
} }
guard let homePageURL = feed.homePageURL else { var homePageURL = feed.homePageURL
return nil if homePageURL == nil {
// Base homePageURL off feedURL if needed. Wont always be accurate, but is good enough.
if let feedURL = URL(string: feed.url), let scheme = feedURL.scheme, let host = feedURL.host {
homePageURL = scheme + "://" + host + "/"
} }
}
if let homePageURL = homePageURL {
return favicon(withHomePageURL: homePageURL) return favicon(withHomePageURL: homePageURL)
} }
return nil
}
func favicon(with faviconURL: String) -> NSImage? { func favicon(with faviconURL: String) -> NSImage? {
let downloader = faviconDownloader(withURL: faviconURL) let downloader = faviconDownloader(withURL: faviconURL)