Merge pull request #232 from maugier/fix/develop/colon_in_suffix
Fix stringification of command suffixes with a leading colon
This commit is contained in:
commit
f76c845979
2 changed files with 26 additions and 1 deletions
|
@ -209,7 +209,7 @@ fn stringify(cmd: &str, args: &[&str]) -> String {
|
|||
Some((suffix, args)) => {
|
||||
let args = args.join(" ");
|
||||
let sp = if args.is_empty() { "" } else { " " };
|
||||
let co = if suffix.is_empty() || suffix.contains(' ') {
|
||||
let co = if suffix.is_empty() || suffix.contains(' ') || suffix.starts_with(':') {
|
||||
":"
|
||||
} else {
|
||||
""
|
||||
|
|
|
@ -547,4 +547,29 @@ mod test {
|
|||
let message = "@tag=\\:\\s\\\\\\r\\na :test PRIVMSG #test test\r\n";
|
||||
assert_eq!(msg, message);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn to_message_with_colon_in_suffix() {
|
||||
let msg = "PRIVMSG #test ::test"
|
||||
.parse::<Message>()
|
||||
.unwrap();
|
||||
let message = Message {
|
||||
tags: None,
|
||||
prefix: None,
|
||||
command: PRIVMSG("#test".to_string(), ":test".to_string())
|
||||
};
|
||||
assert_eq!(msg, message);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn to_string_with_colon_in_suffix() {
|
||||
let msg = Message {
|
||||
tags: None,
|
||||
prefix: None,
|
||||
command: PRIVMSG("#test".to_string(), ":test".to_string()),
|
||||
}
|
||||
.to_string();
|
||||
let message = "PRIVMSG #test ::test\r\n";
|
||||
assert_eq!(msg, message);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue