NetNewsWire/Frameworks/Account/FeedProvider/Twitter/TwitterURL.swift

34 lines
671 B
Swift
Raw Normal View History

2020-04-18 19:03:37 +02:00
//
// TwitterURL.swift
// Account
//
// Created by Maurice Parker on 4/18/20.
// Copyright © 2020 Ranchero Software, LLC. All rights reserved.
//
import Foundation
2020-04-20 02:19:39 +02:00
struct TwitterURL: Codable, TwitterEntity {
2020-04-18 19:03:37 +02:00
let url: String?
let indices: [Int]?
let displayURL: String?
let expandedURL: String?
enum CodingKeys: String, CodingKey {
case url = "url"
case indices = "indices"
case displayURL = "display_url"
case expandedURL = "expanded_url"
2020-04-18 19:03:37 +02:00
}
2020-04-20 02:19:39 +02:00
func renderAsHTML() -> String {
var html = String()
if let expandedURL = expandedURL, let displayURL = displayURL {
html += "<a href=\"\(expandedURL)\">\(displayURL)</a>"
}
return html
2020-04-20 02:19:39 +02:00
}
2020-04-18 19:03:37 +02:00
}