From a0e95d45776297b0f46354ed09ddf6a1d7165d9d Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 12 Apr 2020 12:52:51 -0400 Subject: [PATCH] Remove unnecessary attachment decoding code For some reason, creating a URL from a string decoded from the container was producing URL objects that could not be round-tripped through PropertyListEncoder/Decoder. Decoding a URL directly from the container works correctly. --- Pachyderm/Model/Attachment.swift | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) 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) }