Compare commits
3 Commits
899909b2ed
...
d09aedb5fe
Author | SHA1 | Date |
---|---|---|
p4u1 | d09aedb5fe | |
p4u1 | 37e1b06061 | |
p4u1 | 762a1907ca |
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue