forked from shadowfacts/Tusker
Fix crash when previeiwng non-HTTP(S) link
This commit is contained in:
parent
7904462920
commit
00e8dd6345
|
@ -173,15 +173,17 @@ class ContentTextView: LinkTextView, BaseEmojiLabel {
|
||||||
|
|
||||||
// MARK: - Navigation
|
// 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)
|
let text = (self.text as NSString).substring(with: range)
|
||||||
|
|
||||||
if let mention = getMention(for: url, text: text) {
|
if let mention = getMention(for: url, text: text) {
|
||||||
return ProfileViewController(accountID: mention.id, mastodonController: mastodonController!)
|
return ProfileViewController(accountID: mention.id, mastodonController: mastodonController!)
|
||||||
} else if let tag = getHashtag(for: url, text: text) {
|
} else if let tag = getHashtag(for: url, text: text) {
|
||||||
return HashtagTimelineViewController(for: tag, mastodonController: mastodonController!)
|
return HashtagTimelineViewController(for: tag, mastodonController: mastodonController!)
|
||||||
} else {
|
} else if url.scheme == "https" || url.scheme == "http" {
|
||||||
return SFSafariViewController(url: url)
|
return SFSafariViewController(url: url)
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue