NetNewsWire/Shared/Favicons/FaviconURLFinder.swift

29 lines
609 B
Swift
Raw Normal View History

//
// FaviconURLFinder.swift
2018-08-29 07:18:24 +02:00
// 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 {
2019-12-15 02:01:34 +01:00
static func findFaviconURLs(_ homePageURL: String, _ completion: @escaping ([String]?) -> Void) {
guard let _ = URL(string: homePageURL) else {
2019-12-15 02:01:34 +01:00
completion(nil)
return
}
HTMLMetadataDownloader.downloadMetadata(for: homePageURL) { (htmlMetadata) in
2019-12-15 02:01:34 +01:00
completion(htmlMetadata?.faviconLinks)
}
}
}