mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-12 13:48:06 +00:00
Fixed bad paths causing recursing down scalar values
This commit is contained in:
parent
e4d5769f29
commit
8efc46deae
@ -33,10 +33,10 @@ func recurse(value interface{}, head string, tail []string) interface{} {
|
||||
log.Fatalf("Error accessing array: %v", err)
|
||||
}
|
||||
return readArray(value.([]interface{}), index, tail)
|
||||
case nil:
|
||||
return nil
|
||||
default:
|
||||
case map[interface{}]interface{}:
|
||||
return readMap(value.(map[interface{}]interface{}), head, tail)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,10 @@ func TestReadMap_key_doesnt_exist(t *testing.T) {
|
||||
assertResult(t, nil, readMap(parsedData, "b.x.f", []string{"c"}))
|
||||
}
|
||||
|
||||
func TestReadMap_recurse_against_string(t *testing.T) {
|
||||
assertResult(t, nil, readMap(parsedData, "a", []string{"b"}))
|
||||
}
|
||||
|
||||
func TestReadMap_with_array(t *testing.T) {
|
||||
assertResult(t, 4, readMap(parsedData, "b", []string{"d", "1"}))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user