From 00e8dd63455ffa7ecf822b5d81cdc2971b4dba85 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 6 Dec 2022 10:58:13 -0500 Subject: [PATCH] Fix crash when previeiwng non-HTTP(S) link --- Tusker/Views/ContentTextView.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Tusker/Views/ContentTextView.swift b/Tusker/Views/ContentTextView.swift index e8a2af3c19..ff36eef932 100644 --- a/Tusker/Views/ContentTextView.swift +++ b/Tusker/Views/ContentTextView.swift @@ -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 } }