mirror of
https://github.com/navidrome/navidrome.git
synced 2026-08-01 07:21:17 +00:00
The Fields param was read with StringOr, which keeps only one value, so a request sending it as repeated params (Fields=Genres&Fields=MediaSources) — as Finamp and Feishin do — lost all but the first. Field-gated data like MediaSources was then omitted for Audio items even though the client asked for it; the comma-separated form happened to work because ParseFields splits on commas. Real Jellyfin accepts both forms. ParseFields is now variadic and a parseFields helper reads every repeated value via req.Values.Strings, applied to the item list, single-item, and playlist endpoints.
28 lines
856 B
Go
28 lines
856 B
Go
package dto
|
|
|
|
import "strings"
|
|
|
|
// Fields is the parsed set of a Jellyfin request's Fields param (lowercased). It controls which
|
|
// conditional fields a mapped item carries — chiefly MediaSources — matching real Jellyfin, which
|
|
// omits those unless the client asks for them.
|
|
type Fields map[string]struct{}
|
|
|
|
// ParseFields builds a lowercased set from the Fields param. It accepts each value comma-separated
|
|
// (Fields=a,b) and across repeated params (Fields=a&Fields=b), both of which real Jellyfin honors.
|
|
func ParseFields(values ...string) Fields {
|
|
f := Fields{}
|
|
for _, csv := range values {
|
|
for name := range strings.SplitSeq(csv, ",") {
|
|
if name = strings.TrimSpace(strings.ToLower(name)); name != "" {
|
|
f[name] = struct{}{}
|
|
}
|
|
}
|
|
}
|
|
return f
|
|
}
|
|
|
|
func (f Fields) Has(name string) bool {
|
|
_, ok := f[strings.ToLower(name)]
|
|
return ok
|
|
}
|