From 13a732b5e3816a573f1b4ee995e0b187e81400a1 Mon Sep 17 00:00:00 2001 From: Justin Mazzocchi <2831158+jzzocc@users.noreply.github.com> Date: Thu, 18 Mar 2021 17:51:19 -0700 Subject: [PATCH] Strip whitespace from URL input --- .../Sources/ViewModels/View Models/AddIdentityViewModel.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ViewModels/Sources/ViewModels/View Models/AddIdentityViewModel.swift b/ViewModels/Sources/ViewModels/View Models/AddIdentityViewModel.swift index 8f327f9..d2fb536 100644 --- a/ViewModels/Sources/ViewModels/View Models/AddIdentityViewModel.swift +++ b/ViewModels/Sources/ViewModels/View Models/AddIdentityViewModel.swift @@ -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)