Always show link for images

This commit is contained in:
Maurice Parker 2020-05-12 07:17:32 -05:00
parent cf91632d4a
commit 105fcd7033
1 changed files with 5 additions and 5 deletions

View File

@ -118,7 +118,7 @@ final class RedditLinkData: Codable {
html += "width=\"\(width)\" height=\"\(height)\" "
}
html += "src=\"\(videoPreviewURL)\" autoplay muted></video>"
html += linkOutURL(url)
html += linkURL(url)
return html
}
@ -135,18 +135,18 @@ final class RedditLinkData: Codable {
html += "width=\"\(width)\" height=\"\(height)\" "
}
html += ">"
html += linkOutURL(url)
html += linkURL(url, linkOutOnly: false)
return html
}
return linkOutURL(url)
return linkURL(url)
}
func linkOutURL(_ url: String) -> String {
func linkURL(_ url: String, linkOutOnly: Bool = true) -> String {
guard let urlComponents = URLComponents(string: url), let host = urlComponents.host else {
return ""
}
guard !host.hasSuffix("reddit.com") && !host.hasSuffix("redd.it") else {
guard !linkOutOnly || (!host.hasSuffix("reddit.com") && !host.hasSuffix("redd.it")) else {
return ""
}
var displayURL = "\(urlComponents.host ?? "")\(urlComponents.path)"