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
+4 -4
View File
@@ -166,7 +166,7 @@ final class CommandProcessor {
}
private func handleEmote(_ args: String, command: String, action: String, emoji: String, suffix: String = "") -> CommandResult {
let targetName = args.trimmingCharacters(in: .whitespaces)
let targetName = args.trimmed
guard !targetName.isEmpty else {
return .error(message: "usage: /\(command) <nickname>")
}
@@ -209,7 +209,7 @@ final class CommandProcessor {
}
private func handleBlock(_ args: String) -> CommandResult {
let targetName = args.trimmingCharacters(in: .whitespaces)
let targetName = args.trimmed
if targetName.isEmpty {
// List blocked users (mesh) and geohash (Nostr) blocks
@@ -284,7 +284,7 @@ final class CommandProcessor {
}
private func handleUnblock(_ args: String) -> CommandResult {
let targetName = args.trimmingCharacters(in: .whitespaces)
let targetName = args.trimmed
guard !targetName.isEmpty else {
return .error(message: "usage: /unblock <nickname>")
}
@@ -311,7 +311,7 @@ final class CommandProcessor {
}
private func handleFavorite(_ args: String, add: Bool) -> CommandResult {
let targetName = args.trimmingCharacters(in: .whitespaces)
let targetName = args.trimmed
guard !targetName.isEmpty else {
return .error(message: "usage: /\(add ? "fav" : "unfav") <nickname>")
}