mirror of
https://github.com/antonmedv/fx.git
synced 2024-10-03 21:27:12 +03:00
Allow jsonpath to start with [ char
This commit is contained in:
parent
85f07837f3
commit
c2251d223e
@ -35,6 +35,8 @@ func Split(p string) ([]any, bool) {
|
||||
state = unknown
|
||||
case ch == '.':
|
||||
state = propOrIndex
|
||||
case ch == '[':
|
||||
state = index
|
||||
default:
|
||||
return path, false
|
||||
}
|
||||
|
@ -77,6 +77,14 @@ func Test_SplitPath(t *testing.T) {
|
||||
input: ".foo['bar']['baz\\'']",
|
||||
want: []any{"foo", "bar", "baz\\'"},
|
||||
},
|
||||
{
|
||||
input: "[42]",
|
||||
want: []any{42},
|
||||
},
|
||||
{
|
||||
input: "[42].foo",
|
||||
want: []any{42, "foo"},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.input, func(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user