diff --git a/Pachyderm/Model/Attachment.swift b/Pachyderm/Model/Attachment.swift index 7a9fbbb2..f71a35fa 100644 --- a/Pachyderm/Model/Attachment.swift +++ b/Pachyderm/Model/Attachment.swift @@ -29,18 +29,10 @@ public class Attachment: Codable { let container = try decoder.container(keyedBy: CodingKeys.self) self.id = try container.decode(String.self, forKey: .id) self.kind = try container.decode(Kind.self, forKey: .kind) - self.url = URL(string: try container.decode(String.self, forKey: .url))! - self.previewURL = URL(string: try container.decode(String.self, forKey: .previewURL))! - if let remote = try? container.decode(String.self, forKey: .remoteURL) { - self.remoteURL = URL(string: remote)! - } else { - self.remoteURL = nil - } - if let text = try? container.decode(String.self, forKey: .textURL) { - self.textURL = URL(string: text)! - } else { - self.textURL = nil - } + self.url = try container.decode(URL.self, forKey: .url) + self.previewURL = try container.decode(URL.self, forKey: .previewURL) + self.remoteURL = try? container.decode(URL.self, forKey: .remoteURL) + self.textURL = try? container.decode(URL.self, forKey: .textURL) self.meta = try? container.decode(Metadata.self, forKey: .meta) self.description = try? container.decode(String.self, forKey: .description) }