mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-01-08 15:25:24 +00:00
Safer HTML String decode
This commit is contained in:
parent
523cb48cd1
commit
87471ed9c8
1 changed files with 7 additions and 3 deletions
|
@ -10,9 +10,13 @@ public struct HTMLString: Decodable, Equatable {
|
|||
public let statusesURLs: [URL]
|
||||
public let asSafeMarkdownAttributedString: AttributedString
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.singleValueContainer()
|
||||
htmlValue = try container.decode(String.self)
|
||||
public init(from decoder: Decoder) {
|
||||
do {
|
||||
let container = try decoder.singleValueContainer()
|
||||
htmlValue = try container.decode(String.self)
|
||||
} catch {
|
||||
htmlValue = ""
|
||||
}
|
||||
|
||||
do {
|
||||
asMarkdown = try HTMLParser().parse(html: htmlValue)
|
||||
|
|
Loading…
Reference in a new issue