percent encodes email addresses
This commit is contained in:
parent
c59e3e4ddf
commit
ea77504f3a
|
@ -315,14 +315,12 @@ extension WebViewController: WKNavigationDelegate {
|
|||
} else if components?.scheme == "mailto" {
|
||||
decisionHandler(.cancel)
|
||||
|
||||
guard let _ = url.emailAddress else {
|
||||
guard let emailAddress = URL(string: (url.emailAddress?.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed))!) else {
|
||||
return
|
||||
}
|
||||
|
||||
if UIApplication.shared.canOpenURL(url) {
|
||||
UIApplication.shared.open(url, options: [.universalLinksOnly : false]) { (success) in
|
||||
print(success)
|
||||
}
|
||||
if UIApplication.shared.canOpenURL(emailAddress) {
|
||||
UIApplication.shared.open(emailAddress, options: [.universalLinksOnly : false], completionHandler: nil)
|
||||
} else {
|
||||
let alert = UIAlertController(title: NSLocalizedString("Error", comment: "Error"), message: NSLocalizedString("This device cannot send emails.", comment: "This device cannot send emails."), preferredStyle: .alert)
|
||||
alert.addAction(.init(title: NSLocalizedString("Dismiss", comment: "Dismiss"), style: .cancel, handler: nil))
|
||||
|
|
|
@ -356,14 +356,12 @@ extension WebViewController: WKNavigationDelegate {
|
|||
} else if components?.scheme == "mailto" {
|
||||
decisionHandler(.cancel)
|
||||
|
||||
guard let _ = url.emailAddress else {
|
||||
guard let emailAddress = URL(string: (url.emailAddress?.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed))!) else {
|
||||
return
|
||||
}
|
||||
|
||||
if UIApplication.shared.canOpenURL(url) {
|
||||
UIApplication.shared.open(url, options: [.universalLinksOnly : false]) { (success) in
|
||||
print(success)
|
||||
}
|
||||
if UIApplication.shared.canOpenURL(emailAddress) {
|
||||
UIApplication.shared.open(emailAddress, options: [.universalLinksOnly : false], completionHandler: nil)
|
||||
} else {
|
||||
let alert = UIAlertController(title: NSLocalizedString("Error", comment: "Error"), message: NSLocalizedString("This device cannot send emails.", comment: "This device cannot send emails."), preferredStyle: .alert)
|
||||
alert.addAction(.init(title: NSLocalizedString("Dismiss", comment: "Dismiss"), style: .cancel, handler: nil))
|
||||
|
|
Loading…
Reference in New Issue