forked from shadowfacts/Tusker
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.
This commit is contained in:
parent
465aedd43f
commit
a0e95d4577
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue