diff --git a/Frameworks/Account/FeedProvider/Reddit/RedditLink.swift b/Frameworks/Account/FeedProvider/Reddit/RedditLink.swift index 6fa065e9d..25c29b8e8 100644 --- a/Frameworks/Account/FeedProvider/Reddit/RedditLink.swift +++ b/Frameworks/Account/FeedProvider/Reddit/RedditLink.swift @@ -118,7 +118,7 @@ final class RedditLinkData: Codable { html += "width=\"\(width)\" height=\"\(height)\" " } html += "src=\"\(videoPreviewURL)\" autoplay muted>" - 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)"