Unverified Commit 833a76df authored by bryanl's avatar bryanl
Browse files

decode string with leading 0 as string



When setting parameters, if the value starts with a leading 0 and is
not a float, consider it to be a string.

e.g.:

00: string
0.1: float
0: int
Signed-off-by: default avatarbryanl <bryanliles@gmail.com>
parent dcebde9c
......@@ -248,8 +248,8 @@ func arrayValues(array *ast.Array) ([]interface{}, error) {
}
var (
reFloat = regexp.MustCompile(`^[-+]?[0-9]*\.?[0-9]+$`)
reInt = regexp.MustCompile(`^([+-]?[1-9]\d*|0)$`)
reFloat = regexp.MustCompile(`^[-+]?(0|[1-9]\d+)(\.[0-9]+)*$`)
reInt = regexp.MustCompile(`^([+-]?[1-9]\d*|0{1})$`)
reArray = regexp.MustCompile(`^\[`)
reMap = regexp.MustCompile(`^\{`)
)
......
......@@ -241,6 +241,11 @@ func TestDecodeValue(t *testing.T) {
val: "0",
expected: 0,
},
{
name: "00",
val: "00",
expected: "00",
},
{
name: "bool true",
val: "True",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment