22 lines
585 B
Go
22 lines
585 B
Go
package dashboard
|
|
|
|
import "strings"
|
|
|
|
// splitList parses a textarea/hidden-input value into a clean list,
|
|
// accepting entries separated by newlines and/or commas interchangeably
|
|
// (different forms in this package use one or the other) and dropping
|
|
// blank entries from stray whitespace.
|
|
func splitList(raw string) []string {
|
|
fields := strings.FieldsFunc(raw, func(r rune) bool {
|
|
return r == '\n' || r == '\r' || r == ','
|
|
})
|
|
out := make([]string, 0, len(fields))
|
|
for _, f := range fields {
|
|
f = strings.TrimSpace(f)
|
|
if f != "" {
|
|
out = append(out, f)
|
|
}
|
|
}
|
|
return out
|
|
}
|