Fix crash when previeiwng non-HTTP(S) link

This commit is contained in:
Shadowfacts 2022-12-06 10:58:13 -05:00
parent 7904462920
commit 00e8dd6345
1 changed files with 4 additions and 2 deletions

View File

@ -173,15 +173,17 @@ class ContentTextView: LinkTextView, BaseEmojiLabel {
// MARK: - Navigation
func getViewController(forLink url: URL, inRange range: NSRange) -> UIViewController {
func getViewController(forLink url: URL, inRange range: NSRange) -> UIViewController? {
let text = (self.text as NSString).substring(with: range)
if let mention = getMention(for: url, text: text) {
return ProfileViewController(accountID: mention.id, mastodonController: mastodonController!)
} else if let tag = getHashtag(for: url, text: text) {
return HashtagTimelineViewController(for: tag, mastodonController: mastodonController!)
} else {
} else if url.scheme == "https" || url.scheme == "http" {
return SFSafariViewController(url: url)
} else {
return nil
}
}