Use WebURL for parsing links in HTML

This commit is contained in:
Shadowfacts 2022-03-29 12:40:16 -04:00
parent e09b0ff4e3
commit 6e3089f025
1 changed files with 4 additions and 1 deletions

View File

@ -10,6 +10,8 @@ import UIKit
import SwiftSoup
import Pachyderm
import SafariServices
import WebURL
import WebURLFoundationExtras
private let emojiRegex = try! NSRegularExpression(pattern: ":(\\w+):", options: [])
@ -100,7 +102,8 @@ class ContentTextView: LinkTextView, BaseEmojiLabel {
attributed.append(NSAttributedString(string: "\n"))
case "a":
if let link = try? node.attr("href"),
let url = URL(string: link) {
let webURL = WebURL(link),
let url = URL(webURL) {
attributed.addAttribute(.link, value: url, range: attributed.fullRange)
}
case "p":