Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/ios.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarinofaggiana <ios@nextcloud.com>2022-08-04 15:21:00 +0300
committermarinofaggiana <ios@nextcloud.com>2022-08-04 15:21:00 +0300
commit2ff2808cd9b7444449c3208fb4b97eeb2f687ac9 (patch)
treea5cf5fd0516f634df3caf16eae1915bcbcd0de29
parent530d62efc083414f17b6ae5fbfdcea4e9522f80d (diff)
#2085
Signed-off-by: marinofaggiana <ios@nextcloud.com>
-rw-r--r--iOSClient/Share/NCShare.swift1
-rw-r--r--iOSClient/Utility/NCUtility.swift8
2 files changed, 9 insertions, 0 deletions
diff --git a/iOSClient/Share/NCShare.swift b/iOSClient/Share/NCShare.swift
index ce6d53a66..e9712cfe9 100644
--- a/iOSClient/Share/NCShare.swift
+++ b/iOSClient/Share/NCShare.swift
@@ -185,6 +185,7 @@ class NCShare: UIViewController, NCShareNetworkingDelegate, NCSharePagingContent
@IBAction func searchFieldDidEndOnExit(textField: UITextField) {
guard let searchString = textField.text, !searchString.isEmpty else { return }
+ if searchString.contains("@"), !NCUtility.shared.isValidEmail(searchString) { return }
networking?.getSharees(searchString: searchString)
}
diff --git a/iOSClient/Utility/NCUtility.swift b/iOSClient/Utility/NCUtility.swift
index edbb2fe13..3c1be5e23 100644
--- a/iOSClient/Utility/NCUtility.swift
+++ b/iOSClient/Utility/NCUtility.swift
@@ -1036,6 +1036,14 @@ class NCUtility: NSObject {
}
return ownerId
}
+
+ // https://stackoverflow.com/questions/25471114/how-to-validate-an-e-mail-address-in-swift
+ func isValidEmail(_ email: String) -> Bool {
+
+ let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"
+ let emailPred = NSPredicate(format:"SELF MATCHES %@", emailRegEx)
+ return emailPred.evaluate(with: email)
+ }
}
// MARK: -