mirror of
https://github.com/navidrome/navidrome.git
synced 2026-05-03 06:51:16 +00:00
Merge ea4fe334e6c55b55076925c31277f2b2a372b84a into 94eb6c522b63198bdc4565442d86918ad43156e5
This commit is contained in:
commit
b52de87781
@ -34,23 +34,25 @@ type TagConf struct {
|
|||||||
SplitRx *regexp.Regexp `yaml:"-"`
|
SplitRx *regexp.Regexp `yaml:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SplitTagValue splits a tag value by the split separators, but only if it has a single value.
|
// SplitTagValue splits tag values by the configured split separators.
|
||||||
|
// Each value in the input slice is individually split and trimmed.
|
||||||
func (c TagConf) SplitTagValue(values []string) []string {
|
func (c TagConf) SplitTagValue(values []string) []string {
|
||||||
// If there's not exactly one value or no separators, return early.
|
if c.SplitRx == nil || len(values) == 0 {
|
||||||
if len(values) != 1 || c.SplitRx == nil {
|
|
||||||
return values
|
return values
|
||||||
}
|
}
|
||||||
tag := values[0]
|
|
||||||
|
|
||||||
// Replace all occurrences of any separator with the zero-width space.
|
var result []string
|
||||||
tag = c.SplitRx.ReplaceAllString(tag, consts.Zwsp)
|
for _, tag := range values {
|
||||||
|
// Replace all occurrences of any separator with the zero-width space.
|
||||||
|
tag = c.SplitRx.ReplaceAllString(tag, consts.Zwsp)
|
||||||
|
|
||||||
// Split by the zero-width space and trim each substring.
|
// Split by the zero-width space and trim each substring.
|
||||||
parts := strings.Split(tag, consts.Zwsp)
|
parts := strings.Split(tag, consts.Zwsp)
|
||||||
for i, part := range parts {
|
for _, part := range parts {
|
||||||
parts[i] = strings.TrimSpace(part)
|
result = append(result, strings.TrimSpace(part))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return parts
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
type TagType string
|
type TagType string
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user