Refactoring

This commit is contained in:
Justin Mazzocchi 2020-08-09 13:40:14 -07:00
parent 96fdbad7b9
commit 167a050a89
No known key found for this signature in database
GPG Key ID: E223E6937AAFB01C
2 changed files with 5 additions and 4 deletions

View File

@ -3,15 +3,15 @@
import Foundation
extension String {
private static let colonDoubleSlash = "://"
private static let HTTPSPrefix = "https://"
func url(scheme: String = "https") throws -> URL {
func url() throws -> URL {
let url: URL?
if hasPrefix(scheme + Self.colonDoubleSlash) {
if hasPrefix(Self.HTTPSPrefix) {
url = URL(string: self)
} else {
url = URL(string: scheme + Self.colonDoubleSlash + self)
url = URL(string: Self.HTTPSPrefix + self)
}
guard let validURL = url else { throw URLError(.badURL) }

View File

@ -55,6 +55,7 @@ class AddIdentityViewModel: ObservableObject {
return
}
// TODO: Ensure instance has not disabled public preview
identitiesService.createIdentity(id: identityID, instanceURL: instanceURL)
.map { identityID }
.assignErrorsToAlertItem(to: \.alertItem, on: self)