mailto links now open on iOS

fixes #2036

Extends `URL` with an email address `var` for `mailto` schemes and adds a decisionHandler for `mailto` schemes on `WebViewController`. If the device cannot send mail, an alert is displayed.
This commit is contained in:
Stuart Breckenridge
2020-05-03 21:33:57 +08:00
parent d09541a0c0
commit f901436211
3 changed files with 50 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
//
// URL-Extensions.swift
// NetNewsWire
//
// Created by Stuart Breckenridge on 03/05/2020.
// Copyright © 2020 Ranchero Software. All rights reserved.
//
import Foundation
extension URL {
/// Extracts email address from a `URL` with a `mailto` scheme, otherwise `nil`.
var emailAddress: String? {
scheme == "mailto" ? URLComponents(url: self, resolvingAgainstBaseURL: false)?.path : nil
}
}