Use WebURL for parsing links in HTML
This commit is contained in:
parent
e09b0ff4e3
commit
6e3089f025
|
@ -10,6 +10,8 @@ import UIKit
|
||||||
import SwiftSoup
|
import SwiftSoup
|
||||||
import Pachyderm
|
import Pachyderm
|
||||||
import SafariServices
|
import SafariServices
|
||||||
|
import WebURL
|
||||||
|
import WebURLFoundationExtras
|
||||||
|
|
||||||
private let emojiRegex = try! NSRegularExpression(pattern: ":(\\w+):", options: [])
|
private let emojiRegex = try! NSRegularExpression(pattern: ":(\\w+):", options: [])
|
||||||
|
|
||||||
|
@ -100,7 +102,8 @@ class ContentTextView: LinkTextView, BaseEmojiLabel {
|
||||||
attributed.append(NSAttributedString(string: "\n"))
|
attributed.append(NSAttributedString(string: "\n"))
|
||||||
case "a":
|
case "a":
|
||||||
if let link = try? node.attr("href"),
|
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)
|
attributed.addAttribute(.link, value: url, range: attributed.fullRange)
|
||||||
}
|
}
|
||||||
case "p":
|
case "p":
|
||||||
|
|
Loading…
Reference in New Issue