Compare commits

..

3 Commits

Author SHA1 Message Date
p4u1 d09aedb5fe a little less hacky
continuous-integration/drone/pr Build is failing Details
2023-11-29 21:41:33 +01:00
p4u1 37e1b06061 integreate new modifiers 2023-11-29 21:41:33 +01:00
p4u1 762a1907ca simple modifier implementation 2023-11-29 21:41:26 +01:00
2 changed files with 32 additions and 28 deletions

View File

@ -640,33 +640,33 @@ func TestModfiers(t *testing.T) {
value string
modifiers map[string]string
}{
// "No Modifier": {
// input: "A=a",
// key: "A",
// value: "a",
// },
// "With comment": {
// input: "A=a # my comment",
// key: "A",
// value: "a",
// },
// "With single modifier": {
// input: "A=a # foo=bar",
// key: "A",
// value: "a",
// modifiers: map[string]string{
// "foo": "bar",
// },
// },
// "With multiple modifiers": {
// input: "A=a # foo=bar length=10",
// key: "A",
// value: "a",
// modifiers: map[string]string{
// "foo": "bar",
// "length": "10",
// },
// },
"No Modifier": {
input: "A=a",
key: "A",
value: "a",
},
"With comment": {
input: "A=a # my comment",
key: "A",
value: "a",
},
"With single modifier": {
input: "A=a # foo=bar",
key: "A",
value: "a",
modifiers: map[string]string{
"foo": "bar",
},
},
"With multiple modifiers": {
input: "A=a # foo=bar length=10",
key: "A",
value: "a",
modifiers: map[string]string{
"foo": "bar",
"length": "10",
},
},
"With quoted var": {
input: "A='a' # foo=bar",
key: "A",

View File

@ -178,7 +178,11 @@ func extractVarValue(src []byte, vars map[string]string) (value string, modifier
value = expandVariables(expandEscapes(value), vars)
}
return value, extractModifiers(string(src[i+1 : endOfLine])), src[i+1:], nil
var mods map[string]string
if endOfLine > i {
mods = extractModifiers(string(src[i+1 : endOfLine]))
}
return value, mods, src[i+1:], nil
}
// return formatted error if quoted string is not terminated