From 2a283b4ef7a498aad262f8b13c773f0a63bc14a0 Mon Sep 17 00:00:00 2001 From: Morgan Larosa Date: Wed, 16 Mar 2016 16:11:06 +1100 Subject: [PATCH] Fix #1 --- data_navigator.go | 2 +- data_navigator_test.go | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/data_navigator.go b/data_navigator.go index 55106f2b..fbaf39ca 100644 --- a/data_navigator.go +++ b/data_navigator.go @@ -58,7 +58,7 @@ func recurse(value interface{}, head string, tail []string) interface{} { } func readArray(array []interface{}, head int64, tail []string) interface{} { - if head > int64(len(array)) { + if head >= int64(len(array)) { return nil } diff --git a/data_navigator_test.go b/data_navigator_test.go index c77ea397..eda5f45f 100644 --- a/data_navigator_test.go +++ b/data_navigator_test.go @@ -83,6 +83,17 @@ b: assertResult(t, nil, readMap(data, "b", []string{"d", "3"})) } +func TestReadMap_with_array_out_of_bounds_by_1(t *testing.T) { + var data = parseData(` +--- +b: + d: + - 3 + - 4 +`) + assertResult(t, nil, readMap(data, "b", []string{"d", "2"})) +} + func TestReadMap_with_array_splat(t *testing.T) { var data = parseData(` e: