diff --git a/path.go b/path.go index 088ab6f3..e7a3c724 100644 --- a/path.go +++ b/path.go @@ -501,7 +501,7 @@ func newSelectorNode(selector string) *selectorNode { func (n *selectorNode) filter(node ast.Node) (ast.Node, error) { selector := n.selector - if len(selector) > 0 && selector[0] == '\'' { + if len(selector) > 0 && selector[0] == '\'' && selector[len(selector)-1] == '\'' { selector = selector[1 : len(selector)-1] } switch node.Type() { @@ -517,7 +517,9 @@ func (n *selectorNode) filter(node ast.Node) (ast.Node, error) { return nil, errors.Wrapf(err, "failed to unquote") } case '\'': - key = key[1 : len(key)-1] + if key[len(key)-1] == '\'' { + key = key[1 : len(key)-1] + } } } if key == selector { diff --git a/path_test.go b/path_test.go index c0073cec..0422a0b3 100644 --- a/path_test.go +++ b/path_test.go @@ -100,10 +100,15 @@ store: expected: float64(19.95), }, { - name: `$.store.'bicycle*unicycle'.price`, + name: `$.store.'bicycle*unicycle.price`, path: builder().Root().Child("store").Child(`bicycle*unicycle`).Child("price").Build(), expected: float64(20.25), }, + //{ + // name: `$.store.'bicycle*unicycle.price`, + // path: builder().Root().Child("store").Child(`bicycle*unicycle`).Child("price").Build(), + // expected: float64(20.25), + //}, } t.Run("PathString", func(t *testing.T) { for _, test := range tests {