Trim whitespace off IRC messages

This commit is contained in:
Ken-Håvard Lieng 2017-07-03 23:31:14 +02:00
parent 8a62af5a73
commit 3f70567d56
3 changed files with 14 additions and 2 deletions

View File

@ -131,7 +131,7 @@ func TestRecv(t *testing.T) {
buf.WriteString("001 foo\r\n")
c.reader = bufio.NewReader(buf)
c.sendRecv.Add(2)
c.sendRecv.Add(1)
go c.recv()
assert.Equal(t, "PONG :test\r\n", <-conn.hook)

View File

@ -19,7 +19,7 @@ func (m *Message) LastParam() string {
}
func parseMessage(line string) *Message {
line = strings.Trim(line, "\r\n")
line = strings.Trim(line, "\r\n ")
msg := Message{}
cmdStart := 0
cmdEnd := len(line)

View File

@ -64,6 +64,18 @@ func TestParseMessage(t *testing.T) {
Nick: "ni@ck",
Command: "CMD",
},
}, {
"CMD #cake pie \r\n",
&Message{
Command: "CMD",
Params: []string{"#cake", "pie"},
},
}, {
" CMD #cake pie\r\n",
&Message{
Command: "CMD",
Params: []string{"#cake", "pie"},
},
},
}