mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-24 17:20:59 +00:00
Strip whitespace from URL input
This commit is contained in:
parent
9ff60f65ad
commit
13a732b5e3
1 changed files with 2 additions and 2 deletions
|
@ -30,7 +30,7 @@ public final class AddIdentityViewModel: ObservableObject {
|
|||
.throttle(for: .seconds(Self.textFieldThrottleInterval), scheduler: DispatchQueue.global(), latest: true)
|
||||
.removeDuplicates()
|
||||
.flatMap {
|
||||
instanceURLService.url(text: $0).publisher
|
||||
instanceURLService.url(text: $0.trimmingCharacters(in: .whitespacesAndNewlines)).publisher
|
||||
.map { $0 as URL? }
|
||||
.replaceError(with: nil)
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ public extension AddIdentityViewModel {
|
|||
private extension AddIdentityViewModel {
|
||||
private static let textFieldThrottleInterval: TimeInterval = 0.5
|
||||
func addIdentity(kind: AllIdentitiesService.IdentityCreation) {
|
||||
instanceURLService.url(text: urlFieldText).publisher
|
||||
instanceURLService.url(text: urlFieldText.trimmingCharacters(in: .whitespacesAndNewlines)).publisher
|
||||
.map { ($0, kind) }
|
||||
.flatMap(allIdentitiesService.createIdentity(url:kind:))
|
||||
.receive(on: DispatchQueue.main)
|
||||
|
|
Loading…
Reference in a new issue