traefik/provider/string_util.go

20 lines
490 B
Go
Raw Normal View History

package provider
import "strings"
// SplitAndTrimString splits separatedString at the comma character and trims each
// piece, filtering out empty pieces. Returns the list of pieces or nil if the input
// did not contain a non-empty piece.
2017-11-28 10:16:03 +00:00
func SplitAndTrimString(base string) []string {
var trimmedStrings []string
for _, s := range strings.Split(base, ",") {
s = strings.TrimSpace(s)
if len(s) > 0 {
2017-11-28 10:16:03 +00:00
trimmedStrings = append(trimmedStrings, s)
}
}
2017-11-28 10:16:03 +00:00
return trimmedStrings
}