SFSafariViewController should have method to check if URL can be opened
Originator: | keithbsmiley | ||
Number: | rdar://23697502 | Date Originated: | 30-Nov-2015 04:44 PM |
Status: | Open | Resolved: | |
Product: | iOS SDK | Product Version: | iOS 9.1 |
Classification: | Enhancement | Reproducible: | Always |
Summary: When using SFSafariViewController we noticed that it crashes if it is given URLs that do not match some criteria. It seems like it's specific to the NSURL's scheme being either 'http' or 'https'. It would be nice if these criteria were codified into a method such as `canOpenURL` so we could decided how to handle the URL otherwise. Steps to Reproduce: 1. Create a SFSafariViewController with a bogus NSURL (perhaps `NSURL(string: "")` rdar://23697416) Expected Results: There is some way to determine ahead of time if the app will crash. Actual Results: The app crashes at runtime. Notes: To simulate this functionality we have created a simple SFSafariViewController extension that looks like this: ``` @available(iOS 9.0, *) private extension SFSafariViewController { private class func canOpenURL(URL: NSURL) -> Bool { return URL.host != nil && (URL.scheme == "http" || URL.scheme == "https") } } ```
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!