diff --git a/Shared/Player/Video Details/VideoDescription.swift b/Shared/Player/Video Details/VideoDescription.swift index 1bd12c08..c0b82bf2 100644 --- a/Shared/Player/Video Details/VideoDescription.swift +++ b/Shared/Player/Video Details/VideoDescription.swift @@ -81,29 +81,29 @@ struct VideoDescription: View { // If possibe convert URLs to clickable links #if os(macOS) - @available(macOS 12, *) - struct DescriptionWithLinks: View { - let description: String - let detailsSize: CGSize? - let separators = CharacterSet(charactersIn: " \n") + @available(macOS 12, *) + struct DescriptionWithLinks: View { + let description: String + let detailsSize: CGSize? + let separators = CharacterSet(charactersIn: " \n") - var formattedString: AttributedString { - var attrString = AttributedString(description) - let words = description.unicodeScalars.split(whereSeparator: separators.contains).map(String.init) - words.forEach { word in - if word.hasPrefix("https://") || word.hasPrefix("http://"), let url = URL(string: String(word)) { - if let range = attrString.range(of: word) { - attrString[range].link = url + var formattedString: AttributedString { + var attrString = AttributedString(description) + let words = description.unicodeScalars.split(whereSeparator: separators.contains).map(String.init) + words.forEach { word in + if word.hasPrefix("https://") || word.hasPrefix("http://"), let url = URL(string: String(word)) { + if let range = attrString.range(of: word) { + attrString[range].link = url + } } } + return attrString } - return attrString - } - var body: some View { + var body: some View { Text(formattedString) + } } - } #endif @ViewBuilder var keywords: some View {