From 7183b853bd3eec3d1098d1bc1ccf318d221320de Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Mon, 13 Jul 2020 14:24:57 +0800 Subject: [PATCH] #2256 Fixes #2256 --- Shared/Extensions/URL-Extensions.swift | 9 +++++++++ iOS/Article/WebViewController.swift | 1 + 2 files changed, 10 insertions(+) diff --git a/Shared/Extensions/URL-Extensions.swift b/Shared/Extensions/URL-Extensions.swift index 4fb9b8d7f..5cafe888a 100644 --- a/Shared/Extensions/URL-Extensions.swift +++ b/Shared/Extensions/URL-Extensions.swift @@ -15,4 +15,13 @@ extension URL { scheme == "mailto" ? URLComponents(url: self, resolvingAgainstBaseURL: false)?.path : nil } + func valueFor(_ parameter: String) -> String? { + guard let components = URLComponents(url: self, resolvingAgainstBaseURL: false), + let queryItems = components.queryItems, + let value = queryItems.first(where: { $0.name == parameter })?.value else { + return nil + } + return value + } + } diff --git a/iOS/Article/WebViewController.swift b/iOS/Article/WebViewController.swift index d702b0b87..6ce48e551 100644 --- a/iOS/Article/WebViewController.swift +++ b/iOS/Article/WebViewController.swift @@ -338,6 +338,7 @@ extension WebViewController: WKNavigationDelegate { if MFMailComposeViewController.canSendMail() { let mailComposeViewController = MFMailComposeViewController() mailComposeViewController.setToRecipients([emailAddress]) + mailComposeViewController.setSubject(url.valueFor("subject") ?? "") mailComposeViewController.mailComposeDelegate = self self.present(mailComposeViewController, animated: true, completion: {}) } else {