Add exception handling for Reddit app when sharing since it doesn't pass the URL correctly to the share sheet.

This commit is contained in:
Maurice Parker 2020-10-17 13:00:34 -05:00
parent 97a762a450
commit 6cdb2cbfd0

View File

@ -88,9 +88,12 @@ class ShareViewController: SLComposeServiceViewController, ShareFolderPickerCont
return return
} }
self?.url = url 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 { override func isContentValid() -> Bool {
@ -103,7 +106,11 @@ class ShareViewController: SLComposeServiceViewController, ShareFolderPickerCont
return 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) let request = ExtensionFeedAddRequest(name: name, feedURL: url, destinationContainerID: containerID)
ExtensionFeedAddRequestFile.save(request) ExtensionFeedAddRequestFile.save(request)