Remove baseURL from ArticleRenderer.
This commit is contained in:
parent
c78f5d442d
commit
af150b9b42
|
@ -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
|
||||
}
|
||||
|
||||
// Can’t use url-with-fragment as base URL. The webview won’t 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
|
||||
|
|
Loading…
Reference in New Issue