Remove baseURL from ArticleRenderer.

This commit is contained in:
Brent Simmons 2019-02-12 22:55:26 -08:00
parent c78f5d442d
commit af150b9b42
1 changed files with 0 additions and 32 deletions

View File

@ -13,7 +13,6 @@ import Account
struct ArticleRenderer {
private let baseURL: URL?
private let article: Article?
private let articleStyle: ArticleStyle
private let appearance: NSAppearance?
@ -24,12 +23,6 @@ struct ArticleRenderer {
self.articleStyle = style
self.appearance = appearance
self.title = article?.title ?? ""
if let article = article {
self.baseURL = ArticleRenderer.baseURL(for: article)
}
else {
self.baseURL = nil
}
}
// MARK: - API
@ -48,31 +41,6 @@ struct ArticleRenderer {
let renderer = ArticleRenderer(article: nil, style: style, appearance: appearance)
return renderer.noSelectionHTML
}
static func baseURL(for article: Article) -> URL? {
var s = article.url
if s == nil {
s = article.feed?.homePageURL
}
if s == nil {
s = article.feed?.url
}
guard let urlString = s else {
return nil
}
var urlComponents = URLComponents(string: urlString)
if urlComponents == nil {
return nil
}
// Cant use url-with-fragment as base URL. The webview wont load. See scripting.com/rss.xml for example.
urlComponents!.fragment = nil
guard let url = urlComponents!.url, url.scheme == "http" || url.scheme == "https" else {
return nil
}
return url
}
}
// MARK: - Private