mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-11-05 20:12:58 -05:00
fix(search): resolve KQL path values like the scope path
This commit is contained in:
1 parent
f6a18209ef
commit
4a720c1a86
5 files changed
+26
-5
No files matched your search
@@ -252,6 +252,9 @@ Fixtures:
|
||||
| PATH-08 | `path:"./parent/"` | child.jpg, parent | child.jpg, parent | child.jpg, parent | ✅ |
|
||||
| PATH-09 | `path:"/"` | child.jpg, docs-lower, docs-mixed, docs-upper, parent | child.jpg, docs-lower, docs-mixed, docs-upper, parent | child.jpg, docs-lower, docs-mixed, docs-upper, parent | ✅ |
|
||||
| PATH-10 | `path:""` | child.jpg, docs-lower, docs-mixed, docs-upper, parent | child.jpg, docs-lower, docs-mixed, docs-upper, parent | child.jpg, docs-lower, docs-mixed, docs-upper, parent | ✅ |
|
||||
| PATH-11 | `path:"/parent"` | child.jpg, parent | child.jpg, parent | child.jpg, parent | ✅ |
|
||||
| PATH-12 | `path:"parent"` | child.jpg, parent | child.jpg, parent | child.jpg, parent | ✅ |
|
||||
| PATH-13 | `path:"parent/*"` | child.jpg | child.jpg | child.jpg | ✅ |
|
||||
|
||||
### fields
|
||||
|
||||
|
||||
@@ -25,6 +25,9 @@ func pathGroup() queryGroup {
|
||||
{id: 8, query: `path:"./parent/"`, want: []string{"parent", "child.jpg"}},
|
||||
{id: 9, query: `path:"/"`, want: []string{"parent", "child.jpg", "docs-lower", "docs-upper", "docs-mixed"}},
|
||||
{id: 10, query: `path:""`, want: []string{"parent", "child.jpg", "docs-lower", "docs-upper", "docs-mixed"}},
|
||||
{id: 11, query: `path:"/parent"`, want: []string{"parent", "child.jpg"}},
|
||||
{id: 12, query: `path:"parent"`, want: []string{"parent", "child.jpg"}},
|
||||
{id: 13, query: `path:"parent/*"`, want: []string{"child.jpg"}},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func Test_compile(t *testing.T) {
|
||||
},
|
||||
},
|
||||
want: func() query.Query {
|
||||
tq := query.NewTermQuery("/Foo")
|
||||
tq := query.NewTermQuery("./Foo")
|
||||
tq.SetField("Path")
|
||||
return query.NewConjunctionQuery([]query.Query{tq})
|
||||
}(),
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"strings"
|
||||
|
||||
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
|
||||
"github.com/opencloud-eu/reva/v2/pkg/utils"
|
||||
"reflect"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/pkg/ast"
|
||||
@@ -37,10 +38,7 @@ func normalizeNodes(nodes []ast.Node, resolve func(string) string, defaultKey st
|
||||
case *ast.StringNode:
|
||||
node.Key = resolveKey(node.Key)
|
||||
if FieldIsPath(node.Key) {
|
||||
node.Value = strings.TrimSuffix(node.Value, "/")
|
||||
if node.Value == "" {
|
||||
node.Value = "."
|
||||
}
|
||||
node.Value = utils.MakeRelativePath(node.Value)
|
||||
}
|
||||
if FieldValueIsNormalized(node.Key) {
|
||||
node.Value = strings.ToLower(node.Value)
|
||||
|
||||
@@ -127,6 +127,23 @@ var _ = Describe("Normalize", func() {
|
||||
}))
|
||||
})
|
||||
|
||||
DescribeTable("normalizes path values to the stored relative form",
|
||||
func(in, want string) {
|
||||
got := norm(&ast.StringNode{Key: "path", Value: in})
|
||||
Expect(got).To(Equal([]ast.Node{&ast.StringNode{Key: "Path", Value: want}}))
|
||||
},
|
||||
Entry("relative", "./parent", "./parent"),
|
||||
Entry("trailing slash", "./parent/", "./parent"),
|
||||
Entry("absolute", "/parent", "./parent"),
|
||||
Entry("bare", "parent", "./parent"),
|
||||
Entry("nested bare", "parent/child.jpg", "./parent/child.jpg"),
|
||||
Entry("root", "/", "."),
|
||||
Entry("empty", "", "."),
|
||||
Entry("dot", ".", "."),
|
||||
Entry("wildcard", "*child*", "./*child*"),
|
||||
Entry("wildcard trailing slash", "./par*/", "./par*"),
|
||||
)
|
||||
|
||||
It("converts value nodes to pointers", func() {
|
||||
got := norm(
|
||||
ast.StringNode{Key: "name", Value: "x"},
|
||||
|
||||
Reference in new issue
Block a user