Repository: oragono/oragono (go)

Issue:
ArgsToStrings misses delimiter with one-character args
> MONITOR + a,b,c
> :oragono.test 731 hi a,b,c
> MONITOR L
> :oragono.test 732 hi ab,c
> :oragono.test 733 hi :End of MONITOR list
> MONITOR S
> :oragono.test 731 hi ab,c

Pull request:
Fix issue with one-character args in ArgsToStrings.
Resolves #1086.

Patch:
diff --git a/irc/utils/args.go b/irc/utils/args.go
index 64475da1..ea3f0c96 100644
--- a/irc/utils/args.go
+++ b/irc/utils/args.go
@@ -35,7 +35,7 @@ func ArgsToStrings(maxLength int, arguments []string, delim string) []string {
 			continue
 		}
 
-		if len(buffer) > 1 {
+		if len(buffer) > 0 {
 			buffer += delim
 		}
 		buffer += arguments[0]


Test patch:
diff --git a/irc/utils/args_test.go b/irc/utils/args_test.go
index 5c84b26a..b846d122 100644
--- a/irc/utils/args_test.go
+++ b/irc/utils/args_test.go
@@ -5,6 +5,14 @@ package utils
 
 import "testing"
 
+func TestArgsToStrings(t *testing.T) {
+	val := ArgsToStrings(512, []string{"a", "b", "c"}, ",")
+	assertEqual(val, []string{"a,b,c"}, t)
+
+	val = ArgsToStrings(10, []string{"abcd", "efgh", "ijkl"}, ",")
+	assertEqual(val, []string{"abcd,efgh", "ijkl"}, t)
+}
+
 func TestStringToBool(t *testing.T) {
 	val, err := StringToBool("on")
 	assertEqual(val, true, t)