mirror of
https://github.com/metabolist/metatext.git
synced 2025-01-03 10:38:41 +00:00
Refactoring
This commit is contained in:
parent
96fdbad7b9
commit
167a050a89
2 changed files with 5 additions and 4 deletions
|
@ -3,15 +3,15 @@
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
extension String {
|
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?
|
let url: URL?
|
||||||
|
|
||||||
if hasPrefix(scheme + Self.colonDoubleSlash) {
|
if hasPrefix(Self.HTTPSPrefix) {
|
||||||
url = URL(string: self)
|
url = URL(string: self)
|
||||||
} else {
|
} else {
|
||||||
url = URL(string: scheme + Self.colonDoubleSlash + self)
|
url = URL(string: Self.HTTPSPrefix + self)
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let validURL = url else { throw URLError(.badURL) }
|
guard let validURL = url else { throw URLError(.badURL) }
|
||||||
|
|
|
@ -55,6 +55,7 @@ class AddIdentityViewModel: ObservableObject {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Ensure instance has not disabled public preview
|
||||||
identitiesService.createIdentity(id: identityID, instanceURL: instanceURL)
|
identitiesService.createIdentity(id: identityID, instanceURL: instanceURL)
|
||||||
.map { identityID }
|
.map { identityID }
|
||||||
.assignErrorsToAlertItem(to: \.alertItem, on: self)
|
.assignErrorsToAlertItem(to: \.alertItem, on: self)
|
||||||
|
|
Loading…
Reference in a new issue