mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-26 09:33:25 +01:00
Fix two typos in JSONFeedParser which kept the parser from getting the feed’s favicon and icon URLs. Also added a test for this.
This commit is contained in:
parent
226a7d05b6
commit
e4008b677f
@ -34,8 +34,8 @@ public struct JSONFeedParser {
|
|||||||
let feedURL = parsedObject["feed_url"] as? String ?? parserData.url
|
let feedURL = parsedObject["feed_url"] as? String ?? parserData.url
|
||||||
let feedDescription = parsedObject["description"] as? String
|
let feedDescription = parsedObject["description"] as? String
|
||||||
let nextURL = parsedObject["next_url"] as? String
|
let nextURL = parsedObject["next_url"] as? String
|
||||||
let iconURL = parsedObject["icon_url"] as? String
|
let iconURL = parsedObject["icon"] as? String
|
||||||
let faviconURL = parsedObject["favicon_url"] as? String
|
let faviconURL = parsedObject["favicon"] as? String
|
||||||
let expired = parsedObject["expired"] as? Bool ?? false
|
let expired = parsedObject["expired"] as? Bool ?? false
|
||||||
let hubs = parseHubs(parsedObject)
|
let hubs = parseHubs(parsedObject)
|
||||||
|
|
||||||
@ -149,9 +149,7 @@ private extension JSONFeedParser {
|
|||||||
guard let attachmentsArray = itemDictionary["attachments"] as? JSONArray else {
|
guard let attachmentsArray = itemDictionary["attachments"] as? JSONArray else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return Set(attachmentsArray.flatMap { (oneAttachmentObject) -> ParsedAttachment? in
|
return Set(attachmentsArray.flatMap { parseAttachment($0) })
|
||||||
return parseAttachment(oneAttachmentObject)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static func parseAttachment(_ attachmentObject: JSONDictionary) -> ParsedAttachment? {
|
static func parseAttachment(_ attachmentObject: JSONDictionary) -> ParsedAttachment? {
|
||||||
|
@ -50,4 +50,12 @@ class JSONFeedParserTests: XCTestCase {
|
|||||||
XCTAssert(false, "Expected to find “The Talk Show: ‘I Do Like Throwing a Baby’” article.")
|
XCTAssert(false, "Expected to find “The Talk Show: ‘I Do Like Throwing a Baby’” article.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testGettingFaviconAndIconURLs() {
|
||||||
|
|
||||||
|
let d = parserData("DaringFireball", "json", "http://daringfireball.net/")
|
||||||
|
let parsedFeed = try! FeedParser.parse(d)!
|
||||||
|
|
||||||
|
XCTAssert(parsedFeed.faviconURL == "https://daringfireball.net/graphics/favicon-64.png")
|
||||||
|
XCTAssert(parsedFeed.iconURL == "https://daringfireball.net/graphics/apple-touch-icon.png")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user