NetNewsWire/Shared/Favicons/FaviconURLFinder.swift
Nate Weaver 9de27febf0 Fix favicon loading for sites with multiple/invalid favicons
Load the next favicon if a favicon is invalid

Iterate through multiple favicons and use the first that actually loads

- Add a homePageURL property to SingleFaviconDownloader that notification observers can use.
- Only add a URL to the favicon cache when we're sure it's valid.

Post notification even if the icon failed to load

Update RSParser

Remove single-favicon helper methods

Only load the next favicon if the current load failed

Update RSParser

Make sure to try the default favicon.ico

RSParser test fix update

Update RSParser
2019-11-27 13:02:49 -06:00

29 lines
603 B
Swift

//
// FaviconURLFinder.swift
// NetNewsWire
//
// Created by Brent Simmons on 11/20/17.
// Copyright © 2017 Ranchero Software. All rights reserved.
//
import Foundation
import RSParser
// The favicon URLs may be specified in the head section of the home page.
struct FaviconURLFinder {
static func findFaviconURLs(_ homePageURL: String, _ callback: @escaping ([String]?) -> Void) {
guard let _ = URL(string: homePageURL) else {
callback(nil)
return
}
HTMLMetadataDownloader.downloadMetadata(for: homePageURL) { (htmlMetadata) in
callback(htmlMetadata?.faviconLinks)
}
}
}