Shorten link out URL's

This commit is contained in:
Maurice Parker 2020-05-06 12:39:58 -05:00
parent 38f992d01d
commit 73f9d750b7
1 changed files with 5 additions and 1 deletions

View File

@ -122,7 +122,11 @@ struct RedditLinkData: Codable {
guard !host.hasSuffix("reddit.com") && !host.hasSuffix("redd.it") else { guard !host.hasSuffix("reddit.com") && !host.hasSuffix("redd.it") else {
return "" return ""
} }
return "<div><a href=\"\(url)\">\(url)</a></div>" var displayURL = "\(urlComponents.host ?? "")\(urlComponents.path)"
if displayURL.count > 30 {
displayURL = "\(displayURL.prefix(30))..."
}
return "<div><a href=\"\(url)\">\(displayURL)</a></div>"
} }
} }