Create a special case for the Relay blog relay.fm/blog for the feed finder. Fixes #5299.

This commit is contained in:
Brent Simmons committed 2026-08-02 13:03:19 -07:00
1 parent 554ada15b8
commit caba227eb0
4 files changed
+41

No files matched your search

@@ -40,6 +40,13 @@ public struct FeedSpecifier: Hashable, Sendable {
return FeedSpecifier(title: "writing - rachelbythebay", urlString: feedURLString, source: .userEntered, orderFound: 0)
}
// The blog page only advertises the master podcast feed in its <head>, so the finder would
// otherwise miss the blog feed. <https://github.com/Ranchero-Software/NetNewsWire/issues/5299>
if url.isRelayFMBlogURL {
let feedURLString = "https://www.relay.fm/blog/feed"
return FeedSpecifier(title: "Relay FM Blog", urlString: feedURLString, source: .userEntered, orderFound: 0)
}
return nil
}
@@ -15,4 +15,13 @@ final class FeedFinderTests: XCTestCase {
let feedFinder = FeedFinder()
XCTAssertNotNil(feedFinder)
}
func testKnownFeedSpecifierForRelayFMBlog() throws {
let specifier = FeedSpecifier.knownFeedSpecifier(url: URL(string: "https://www.relay.fm/blog")!)
XCTAssertEqual(specifier?.urlString, "https://www.relay.fm/blog/feed")
}
func testKnownFeedSpecifierIgnoresRelayFMRoot() throws {
XCTAssertNil(FeedSpecifier.knownFeedSpecifier(url: URL(string: "https://www.relay.fm")!))
}
}
@@ -15,6 +15,7 @@ nonisolated public struct SpecialCase {
public static let openRSSOrgHostName = "openrss.org"
public static let youtubeHostName = "youtube.com"
public static let redditHostName = "reddit.com"
public static let relayFMHostName = "relay.fm"
public static func urlStringContainSpecialCase(_ urlString: String, _ specialCases: [String]) -> Bool {
let lowerURLString = urlString.lowercased(with: localeForLowercasing)
@@ -84,6 +85,16 @@ nonisolated extension URL {
public var isRedditURL: Bool {
SpecialCase.urlStringMatchesDomain(absoluteString, [SpecialCase.redditHostName])
}
/// The Relay FM blog, specifically — not the whole relay.fm domain (its root advertises the master
/// podcast feed). Matches the /blog index and /blog/<post> pages.
public var isRelayFMBlogURL: Bool {
guard SpecialCase.urlStringMatchesDomain(absoluteString, [SpecialCase.relayFMHostName]) else {
return false
}
let path = path()
return path == "/blog" || path.hasPrefix("/blog/")
}
}
nonisolated extension Set where Element == URL {
@@ -23,4 +23,18 @@ struct SpecialCasesTests {
#expect(!URL(string: "https://reddit.com.evil.example/feed")!.isRedditURL)
#expect(!URL(string: "https://example.com/r/reddit.com")!.isRedditURL)
}
@Test func isRelayFMBlogURLMatchesBlog() {
#expect(URL(string: "https://www.relay.fm/blog")!.isRelayFMBlogURL)
#expect(URL(string: "http://relay.fm/blog")!.isRelayFMBlogURL)
#expect(URL(string: "https://www.relay.fm/blog/")!.isRelayFMBlogURL)
#expect(URL(string: "https://www.relay.fm/blog/some-post")!.isRelayFMBlogURL)
}
@Test func isRelayFMBlogURLRejectsNonBlog() {
#expect(!URL(string: "https://relay.fm")!.isRelayFMBlogURL) // root → master feed
#expect(!URL(string: "http://relay.fm/master/feed")!.isRelayFMBlogURL)
#expect(!URL(string: "https://www.relay.fm/blogsomething")!.isRelayFMBlogURL)
#expect(!URL(string: "https://relay.fm.evil.example/blog")!.isRelayFMBlogURL) // host check
}
}