Return an empty slice for empty string lists

This commit is contained in:
Svend Sorensen 2015-10-07 13:28:46 -07:00 committed by Anthony Stanton
parent 53f44878ff
commit 8e4a313f17
1 changed files with 3 additions and 3 deletions

View File

@ -69,11 +69,11 @@ func (sl StringList) Length() int {
func (sl StringList) Slice() []string {
parts := strings.Split(string(sl), stringListDelim)
// split on an empty StringList will have a length of 2, since there is
// always at least one deliminator
switch len(parts) {
case 0, 1:
case 0, 1, 2:
return []string{}
case 2:
return []string{""}
}
// strip empty elements generated by leading and trailing delimiters