String trimming in a centralized manner (#1079)

* String trimming in a centralized manner

* Fix empty-nickname case
This commit is contained in:
Islam
2026-04-04 15:56:39 -05:00
committed by GitHub
parent b5834cfc76
commit 473f5c7cce
18 changed files with 81 additions and 79 deletions
+2 -2
View File
@@ -302,7 +302,7 @@ struct LocationChannelsSheet: View {
}
}
let normalized = customGeohash
.trimmingCharacters(in: .whitespacesAndNewlines)
.trimmed
.lowercased()
.replacingOccurrences(of: "#", with: "")
let isValid = validateGeohash(normalized)
@@ -449,7 +449,7 @@ struct LocationChannelsSheet: View {
// Split a title like "#mesh [3 people]" into base and suffix "[3 people]"
private func splitTitleAndCount(_ s: String) -> (base: String, countSuffix: String?) {
guard let idx = s.lastIndex(of: "[") else { return (s, nil) }
let prefix = String(s[..<idx]).trimmingCharacters(in: .whitespaces)
let prefix = String(s[..<idx]).trimmed
let suffix = String(s[idx...])
return (prefix, suffix)
}