Skip to content

Commit

Permalink
Handle path parser non-array case (#1427)
Browse files Browse the repository at this point in the history
  • Loading branch information
phanimarupaka committed Feb 8, 2021
1 parent 1a13ac1 commit 34bc5a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/util/search/pathparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func elementMatch(elem, pattern string) bool {
if patternParts[0] != "*" && elemParts[0] != patternParts[0] {
return false
}
return patternParts[1] == "*]" || elemParts[1] == patternParts[1]
return len(patternParts) > 1 && (patternParts[1] == "*]" || elemParts[1] == patternParts[1])
}
return false
}
Expand Down
6 changes: 6 additions & 0 deletions internal/util/search/pathparser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ var tests = []test{
traversedPath: "a.c[2].c[0].d.e[1].f",
shouldMatch: false,
},
{
name: "compare normal path with array path",
byPath: "a.c",
traversedPath: "a.c[0]",
shouldMatch: false,
},
}

func TestPathMatch(t *testing.T) {
Expand Down

0 comments on commit 34bc5a8

Please sign in to comment.