Centralize logic for when to use the nnw feed icon.
This commit is contained in:
parent
9e4fb8a7d3
commit
bdd858f509
@ -123,7 +123,7 @@ final class FaviconDownloader {
|
||||
let url = homePageURL.normalizedURL
|
||||
|
||||
if let url = URL(string: homePageURL) {
|
||||
if url.host == "nnw.ranchero.com" || url.host == "netnewswire.blog" {
|
||||
if ImageUtilities.shouldUseNNWFeedIcon(with: url) {
|
||||
return IconImage.nnwFeedIcon
|
||||
}
|
||||
}
|
||||
|
@ -50,8 +50,8 @@ public final class FeedIconDownloader {
|
||||
if let cachedImage = cache[feed] {
|
||||
return cachedImage
|
||||
}
|
||||
|
||||
if let homePageURLString = feed.homePageURL, let homePageURL = URL(string: homePageURLString), (homePageURL.host == "nnw.ranchero.com" || homePageURL.host == "netnewswire.blog") {
|
||||
|
||||
if let feedURL = URL(string: feed.url), ImageUtilities.shouldUseNNWFeedIcon(with: feedURL) {
|
||||
return IconImage.nnwFeedIcon
|
||||
}
|
||||
|
||||
|
34
Shared/Images/ImageUtilities.swift
Normal file
34
Shared/Images/ImageUtilities.swift
Normal file
@ -0,0 +1,34 @@
|
||||
//
|
||||
// ImageUtilities.swift
|
||||
// NetNewsWire
|
||||
//
|
||||
// Created by Brent Simmons on 1/19/25.
|
||||
// Copyright © 2025 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
struct ImageUtilities {
|
||||
|
||||
static func shouldUseNNWFeedIcon(with feedURL: URL) -> Bool {
|
||||
|
||||
guard let host = feedURL.host() else {
|
||||
return false
|
||||
}
|
||||
|
||||
if host == "nnw.ranchero.com" || host == "netnewswire.blog" {
|
||||
return true
|
||||
}
|
||||
if host != "ranchero.com" {
|
||||
return false
|
||||
}
|
||||
|
||||
let absoluteString = feedURL.absoluteString
|
||||
if absoluteString == "https://ranchero.com/downloads/netnewswire-beta.xml" || absoluteString == "https://ranchero.com/downloads/netnewswire-release.xml" {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user