From e4008b677ffd594f7efccb53b2cfffb1f7e47e8f Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sat, 25 Nov 2017 10:34:48 -0800 Subject: [PATCH] =?UTF-8?q?Fix=20two=20typos=20in=20JSONFeedParser=20which?= =?UTF-8?q?=20kept=20the=20parser=20from=20getting=20the=20feed=E2=80=99s?= =?UTF-8?q?=20favicon=20and=20icon=20URLs.=20Also=20added=20a=20test=20for?= =?UTF-8?q?=20this.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frameworks/RSParser/Feeds/JSON/JSONFeedParser.swift | 8 +++----- .../RSParser/RSParserTests/JSONFeedParserTests.swift | 8 ++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Frameworks/RSParser/Feeds/JSON/JSONFeedParser.swift b/Frameworks/RSParser/Feeds/JSON/JSONFeedParser.swift index c97744244..f05a0fcc7 100644 --- a/Frameworks/RSParser/Feeds/JSON/JSONFeedParser.swift +++ b/Frameworks/RSParser/Feeds/JSON/JSONFeedParser.swift @@ -34,8 +34,8 @@ public struct JSONFeedParser { let feedURL = parsedObject["feed_url"] as? String ?? parserData.url let feedDescription = parsedObject["description"] as? String let nextURL = parsedObject["next_url"] as? String - let iconURL = parsedObject["icon_url"] as? String - let faviconURL = parsedObject["favicon_url"] as? String + let iconURL = parsedObject["icon"] as? String + let faviconURL = parsedObject["favicon"] as? String let expired = parsedObject["expired"] as? Bool ?? false let hubs = parseHubs(parsedObject) @@ -149,9 +149,7 @@ private extension JSONFeedParser { guard let attachmentsArray = itemDictionary["attachments"] as? JSONArray else { return nil } - return Set(attachmentsArray.flatMap { (oneAttachmentObject) -> ParsedAttachment? in - return parseAttachment(oneAttachmentObject) - }) + return Set(attachmentsArray.flatMap { parseAttachment($0) }) } static func parseAttachment(_ attachmentObject: JSONDictionary) -> ParsedAttachment? { diff --git a/Frameworks/RSParser/RSParserTests/JSONFeedParserTests.swift b/Frameworks/RSParser/RSParserTests/JSONFeedParserTests.swift index b7e1a34c4..f7c45d309 100644 --- a/Frameworks/RSParser/RSParserTests/JSONFeedParserTests.swift +++ b/Frameworks/RSParser/RSParserTests/JSONFeedParserTests.swift @@ -50,4 +50,12 @@ class JSONFeedParserTests: XCTestCase { 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") + } }