Add https:// to a source URL if you forget the scheme (#361)

This commit is contained in:
Theodore Dubois
2020-09-27 13:56:54 -07:00
committed by GitHub
parent 615d4fb35b
commit b291f7b606

View File

@@ -106,7 +106,12 @@ private extension SourcesViewController
}
alertController.addAction(.cancel)
alertController.addAction(UIAlertAction(title: NSLocalizedString("Add", comment: ""), style: .default) { (action) in
guard let text = alertController.textFields![0].text, let sourceURL = URL(string: text) else { return }
guard let text = alertController.textFields![0].text else { return }
guard var sourceURL = URL(string: text) else { return }
if sourceURL.scheme == nil {
guard let httpsSourceURL = URL(string: "https://" + text) else { return }
sourceURL = httpsSourceURL
}
self.addSource(url: sourceURL)
})