2017-11-20 22:16:06 +01:00
|
|
|
//
|
|
|
|
// FaviconURLFinder.swift
|
|
|
|
// Evergreen
|
|
|
|
//
|
|
|
|
// Created by Brent Simmons on 11/20/17.
|
|
|
|
// Copyright © 2017 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import RSParser
|
|
|
|
|
|
|
|
// The favicon URL may be specified in the head section of the home page.
|
|
|
|
|
|
|
|
struct FaviconURLFinder {
|
|
|
|
|
|
|
|
static func findFaviconURL(_ homePageURL: String, _ callback: @escaping (String?) -> Void) {
|
|
|
|
|
2017-12-18 19:20:28 +01:00
|
|
|
guard let _ = URL(string: homePageURL) else {
|
2017-11-20 22:16:06 +01:00
|
|
|
callback(nil)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-12-18 19:20:28 +01:00
|
|
|
HTMLMetadataDownloader.downloadMetadata(for: homePageURL) { (htmlMetadata) in
|
|
|
|
callback(htmlMetadata?.faviconLink)
|
2017-12-14 04:46:03 +01:00
|
|
|
}
|
2017-11-20 22:16:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|