From 9b982a82c150c65a5f72c9b548053553b2c3b0fb Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Sun, 19 Apr 2020 22:00:56 +0200 Subject: Store path as array -- the delimiter is not always '.' --- internal/config/yaml.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'internal/config/yaml.go') diff --git a/internal/config/yaml.go b/internal/config/yaml.go index 8c40107..80fb383 100644 --- a/internal/config/yaml.go +++ b/internal/config/yaml.go @@ -27,7 +27,7 @@ func (grpFeed *configGroupFeed) isGroup() bool { } func (grpFeed *configGroupFeed) isFeed() bool { - return grpFeed.Feed != Feed{} + return grpFeed.Feed.Name != "" || grpFeed.Feed.Url != "" } func (grpFeed *configGroupFeed) target() string { @@ -51,20 +51,21 @@ func parse(buf []byte) (config, error) { return parsedCfg, nil } -func appTarget(target, app string) string { - if target == "" { - return app - } - - if app == "" { +func appTarget(target []string, app string) []string { + switch { + case len(target) == 0 && app == "": + return []string{} + case len(target) == 0: + return []string{app} + case app == "": return target + default: + return append(target, app) } - - return target + "." + app } // Parse the group structure and populate the `Target` fields in the feeds -func buildFeeds(cfg []configGroupFeed, target string, feeds Feeds) error { +func buildFeeds(cfg []configGroupFeed, target []string, feeds Feeds) error { for idx := range cfg { f := &cfg[idx] // cannot use `_, f := range cfg` as it returns copies(!), but we need the originals target := appTarget(target, f.target()) -- cgit v1.2.3-54-g00ecf