Add https if there's no prefix (IOS-141)

This commit is contained in:
Nathan Mattes 2023-09-18 17:58:17 +02:00
parent 5cb1280088
commit fa6b3fed24
1 changed files with 14 additions and 2 deletions

View File

@ -282,8 +282,20 @@ class SearchResultsOverviewTableViewController: UIViewController, NeedsDependenc
target: .status, // remove reblog wrapper
status: status.asRecord
)
} else if let url = URL(string: link) {
coordinator.present(scene: .safari(url: url), transition: .safariPresent(animated: true))
} else if var url = URL(string: link) {
let prefixedURL: URL?
if var components = URLComponents(url: url, resolvingAgainstBaseURL: false) {
if components.scheme == nil {
components.scheme = "https"
}
prefixedURL = components.url
} else {
prefixedURL = url
}
guard let prefixedURL else { return }
coordinator.present(scene: .safari(url: prefixedURL), transition: .safariPresent(animated: true))
}
}
}