1
0
mirror of https://github.com/taigrr/yq synced 2025-01-18 04:53:17 -08:00

Fix path generation when merging file has period in key

The program generates a path for every leaf node in the
file-to-be-merged. It does not escape them if they contain a dot, as
the path-expressions document mentions is necessary.

Add in a test for this condition. Verified it fails without the fix.
This commit is contained in:
Cory Cross
2020-02-04 22:27:08 -08:00
parent 699fce9da4
commit ea9df0eede
3 changed files with 14 additions and 6 deletions

View File

@@ -51,7 +51,15 @@ func mergePathStackToString(pathStack []interface{}, appendArrays bool) string {
}
default:
sb.WriteString(fmt.Sprintf("%v", path))
s := fmt.Sprintf("%v", path)
hasDot := strings.Contains(s, ".")
if hasDot {
sb.WriteString("[")
}
sb.WriteString(s)
if hasDot {
sb.WriteString("]")
}
}
if index < len(pathStack)-1 {