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