From 6cdb2cbfd01cf0be9193e9d1201bc135828ef967 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 17 Oct 2020 13:00:34 -0500 Subject: [PATCH] Add exception handling for Reddit app when sharing since it doesn't pass the URL correctly to the share sheet. --- iOS/ShareExtension/ShareViewController.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/iOS/ShareExtension/ShareViewController.swift b/iOS/ShareExtension/ShareViewController.swift index b1701c396..9da5495db 100644 --- a/iOS/ShareExtension/ShareViewController.swift +++ b/iOS/ShareExtension/ShareViewController.swift @@ -88,9 +88,12 @@ class ShareViewController: SLComposeServiceViewController, ShareFolderPickerCont return } self?.url = url + return }) } + // Reddit in particular doesn't pass the URL correctly and instead puts it in the contentText + url = URL(string: contentText) } override func isContentValid() -> Bool { @@ -103,7 +106,11 @@ class ShareViewController: SLComposeServiceViewController, ShareFolderPickerCont return } - let name = contentText.isEmpty ? nil : contentText + var name: String? = nil + if !contentText.mayBeURL { + name = contentText.isEmpty ? nil : contentText + } + let request = ExtensionFeedAddRequest(name: name, feedURL: url, destinationContainerID: containerID) ExtensionFeedAddRequestFile.save(request)