diff options
Diffstat (limited to 'tvloader/parser2v1/util.go')
-rw-r--r-- | tvloader/parser2v1/util.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tvloader/parser2v1/util.go b/tvloader/parser2v1/util.go new file mode 100644 index 0000000..ed99063 --- /dev/null +++ b/tvloader/parser2v1/util.go @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later + +package parser2v1 + +import ( + "fmt" + "strings" +) + +// used to extract key / value from embedded substrings +// returns subkey, subvalue, nil if no error, or "", "", error otherwise +func extractSubs(value string) (string, string, error) { + // parse the value to see if it's a valid subvalue format + sp := strings.SplitN(value, ":", 2) + if len(sp) == 1 { + return "", "", fmt.Errorf("invalid subvalue format for %s (no colon found)", value) + } + + subkey := strings.TrimSpace(sp[0]) + subvalue := strings.TrimSpace(sp[1]) + + return subkey, subvalue, nil +} |