commit 29c41708332bd6855a0cc23400f76274d228cbbc
parent 3c629621eb393a6e14945ee131fb1e92667f48ed
Author: William Casarin <jb55@jb55.com>
Date: Tue, 7 Feb 2023 12:07:20 -0800
Make @ mentions case insensitive
Changelog-Fixed: Make @ mentions case insensitive
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/damus/Views/Posting/UserSearch.swift b/damus/Views/Posting/UserSearch.swift
@@ -57,8 +57,10 @@ struct UserSearch_Previews: PreviewProvider {
}
-func search_users(profiles: Profiles, tags: [[String]], search: String) -> [SearchedUser] {
+func search_users(profiles: Profiles, tags: [[String]], search _search: String) -> [SearchedUser] {
var seen_user = Set<String>()
+ let search = _search.lowercased()
+
return tags.reduce(into: Array<SearchedUser>()) { arr, tag in
guard tag.count >= 2 && tag[0] == "p" else {
return
@@ -77,7 +79,7 @@ func search_users(profiles: Profiles, tags: [[String]], search: String) -> [Sear
let profile = profiles.lookup(id: pubkey)
- guard ((petname?.hasPrefix(search) ?? false) || (profile?.name?.hasPrefix(search) ?? false)) else {
+ guard ((petname?.lowercased().hasPrefix(search) ?? false) || (profile?.name?.lowercased().hasPrefix(search) ?? false)) else {
return
}