Merge pull request #44 from slingamn/newline_trim

IRCReader: trim \r if the line ending was \r\n
This commit is contained in:
Shivaram Lingamneni 2021-03-01 18:47:05 -05:00 committed by GitHub
commit d39993c074
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -63,6 +63,10 @@ func (cc *IRCReader) ReadLine() ([]byte, error) {
line := cc.buf[cc.start : cc.searchFrom+nlidx]
cc.start = cc.searchFrom + nlidx + 1
cc.searchFrom = cc.start
// treat \r\n as the line terminator if it was present
if 0 < len(line) && line[len(line)-1] == '\r' {
line = line[:len(line)-1]
}
return line, nil
}