mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Add Atom feed detection to FeedType.
This commit is contained in:
@@ -10,7 +10,7 @@ import Foundation
|
||||
import SAX
|
||||
|
||||
public enum FeedType: Sendable {
|
||||
|
||||
|
||||
case rss
|
||||
case atom
|
||||
case jsonFeed
|
||||
@@ -42,6 +42,9 @@ public enum FeedType: Sendable {
|
||||
if isProbablyRSS(cCharPointer, count) {
|
||||
return .rss
|
||||
}
|
||||
if isProbablyAtom(cCharPointer, count) {
|
||||
return .atom
|
||||
}
|
||||
|
||||
return .unknown
|
||||
}
|
||||
@@ -82,6 +85,11 @@ private extension FeedType {
|
||||
return didFindString("<channel>", bytes, count) && didFindString("<pubDate>", bytes, count)
|
||||
}
|
||||
|
||||
static func isProbablyAtom(_ bytes: UnsafePointer<CChar>, _ count: Int) -> Bool {
|
||||
|
||||
didFindString("<feed", bytes, count)
|
||||
}
|
||||
|
||||
static func didFindString(_ string: UnsafePointer<CChar>, _ bytes: UnsafePointer<CChar>, _ numberOfBytes: Int) -> Bool {
|
||||
|
||||
let foundString = strnstr(bytes, string, numberOfBytes)
|
||||
|
||||
Reference in New Issue
Block a user