2017-11-20 13:16:06 -08:00
|
|
|
//
|
|
|
|
// FaviconURLFinder.swift
|
2018-08-28 22:18:24 -07:00
|
|
|
// NetNewsWire
|
2017-11-20 13:16:06 -08:00
|
|
|
//
|
|
|
|
// Created by Brent Simmons on 11/20/17.
|
|
|
|
// Copyright © 2017 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import RSParser
|
|
|
|
|
2019-11-25 19:54:09 -06:00
|
|
|
// The favicon URLs may be specified in the head section of the home page.
|
2017-11-20 13:16:06 -08:00
|
|
|
|
|
|
|
struct FaviconURLFinder {
|
|
|
|
|
2019-11-25 19:54:09 -06:00
|
|
|
static func findFaviconURLs(_ homePageURL: String, _ callback: @escaping ([String]?) -> Void) {
|
2017-11-20 13:16:06 -08:00
|
|
|
|
2017-12-18 10:20:28 -08:00
|
|
|
guard let _ = URL(string: homePageURL) else {
|
2017-11-20 13:16:06 -08:00
|
|
|
callback(nil)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-12-18 10:20:28 -08:00
|
|
|
HTMLMetadataDownloader.downloadMetadata(for: homePageURL) { (htmlMetadata) in
|
2019-11-25 19:54:09 -06:00
|
|
|
callback(htmlMetadata?.faviconLinks)
|
2017-12-13 19:46:03 -08:00
|
|
|
}
|
2017-11-20 13:16:06 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|