Skip to content

Commit

Permalink
fix: Correct root path handling (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
nieomylnieja authored Jul 5, 2024
1 parent b2a8cc6 commit 22fcf1c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion path.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ func (n *rootNode) String() string {

func (n *rootNode) filter(node ast.Node) (ast.Node, error) {
if n.child == nil {
return nil, nil
return node, nil
}
filtered, err := n.child.filter(node)
if err != nil {
Expand Down
25 changes: 25 additions & 0 deletions path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,31 @@ store:
path: builder().Root().Child("store").Child(`bicycle*unicycle`).Child("price").Build(),
expected: float64(20.25),
},
{
name: "$",
path: builder().Root().Build(),
expected: map[string]interface{}{
"store": map[string]interface{}{
"book": []interface{}{
map[string]interface{}{
"author": "john",
"price": uint64(10),
},
map[string]interface{}{
"author": "ken",
"price": uint64(12),
},
},
"bicycle": map[string]interface{}{
"color": "red",
"price": 19.95,
},
"bicycle*unicycle": map[string]interface{}{
"price": 20.25,
},
},
},
},
}
t.Run("PathString", func(t *testing.T) {
for _, test := range tests {
Expand Down

0 comments on commit 22fcf1c

Please # to comment.