// Copyright 2026 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT package utils import "strings" // SplitCSV parses val as a comma-separated list, trimming whitespace and // dropping empty entries (e.g. "alice,,bob" -> ["alice", "bob"]). Returns // nil (not an empty slice) when no non-empty entries remain, so callers // can use len(x) == 0 unambiguously and the result round-trips cleanly // through encoding/json (a nil slice marshals as null and is omitted by // most Gitea API endpoints that use omitempty). func SplitCSV(val string) []string { if val == "" { return nil } parts := strings.Split(val, ",") var out []string for _, p := range parts { p = strings.TrimSpace(p) if p == "" { continue } out = append(out, p) } return out }