summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlara Modin <klarasmodin@gmail.com>2022-06-20 20:50:11 +0200
committerKlara Modin <klarasmodin@gmail.com>2022-06-20 20:50:11 +0200
commit238efcfa08ca9c4f04d73d5de79c796c6eca6f60 (patch)
tree197f4b994b97a752f45edaeaea4dcb890d6b3895
parentadc7fe26cfdeb0e282a79642f20c90980d3eab6c (diff)
improve handling of trailing strings
-rw-r--r--src/server_int.rs15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/server_int.rs b/src/server_int.rs
index b5077db..cd6d52b 100644
--- a/src/server_int.rs
+++ b/src/server_int.rs
@@ -72,24 +72,21 @@ impl Message {
message.command = part.next()
.map_or(String::new(), |x| x.to_string().to_uppercase());
- let mut is_trailing = false;
let mut trailing = String::new();
while let Some(p) = part.next() {
if p.starts_with(":") {
- is_trailing = true;
trailing = p.to_string();
trailing.remove(0);
- trailing.push(' ');
- } else if is_trailing {
- trailing.push_str(p);
- trailing.push(' ');
+ while let Some(p) = part.next() {
+ trailing.push(' ');
+ trailing.push_str(p);
+ }
+ message.params.push(trailing.to_string());
+ break;
} else {
message.params.push(p.to_string());
}
}
- if is_trailing {
- message.params.push(trailing.trim().to_string());
- }
message
}