diff --git a/Frameworks/RSParser/Feeds/JSON/RSSInJSONParser.swift b/Frameworks/RSParser/Feeds/JSON/RSSInJSONParser.swift index 8a510f711..8debc2a66 100644 --- a/Frameworks/RSParser/Feeds/JSON/RSSInJSONParser.swift +++ b/Frameworks/RSParser/Feeds/JSON/RSSInJSONParser.swift @@ -172,7 +172,9 @@ private extension RSSInJSONParser { } let type = enclosureObject["type"] as? String - let oneAttachment = ParsedAttachment(url: attachmentURL, mimeType: type, title: nil, sizeInBytes: attachmentSize, durationInSeconds: nil) - return Set([oneAttachment]) + if let attachment = ParsedAttachment(url: attachmentURL, mimeType: type, title: nil, sizeInBytes: attachmentSize, durationInSeconds: nil) { + return Set([attachment]) + } + return nil } } diff --git a/Frameworks/RSParser/Feeds/ParsedAttachment.swift b/Frameworks/RSParser/Feeds/ParsedAttachment.swift index 29520033a..bb836948e 100644 --- a/Frameworks/RSParser/Feeds/ParsedAttachment.swift +++ b/Frameworks/RSParser/Feeds/ParsedAttachment.swift @@ -10,33 +10,21 @@ import Foundation public struct ParsedAttachment: Hashable { - public let url: String? + public let url: String public let mimeType: String? public let title: String? public let sizeInBytes: Int? public let durationInSeconds: Int? public let hashValue: Int - init(url: String?, mimeType: String?, title: String?, sizeInBytes: Int?, durationInSeconds: Int?) { + init?(url: String, mimeType: String?, title: String?, sizeInBytes: Int?, durationInSeconds: Int?) { self.url = url self.mimeType = mimeType self.title = title self.sizeInBytes = sizeInBytes self.durationInSeconds = durationInSeconds - - var stringToHash = "" - stringToHash += url ?? "" - stringToHash += mimeType ?? "" - stringToHash += title ?? "" - var h = stringToHash.hashValue - if let sizeInBytes = sizeInBytes { - h = h ^ sizeInBytes.hashValue - } - if let durationInSeconds = durationInSeconds { - h = h ^ durationInSeconds.hashValue - } - self.hashValue = h + self.hashValue = url.hashValue } public static func ==(lhs: ParsedAttachment, rhs: ParsedAttachment) -> Bool {