fix: search case sensitiveness (#515)
Former-commit-id: 7d86ecccd2095be6bf7db6fa4b93e226cb590661 [formerly c6e3db510232dad7f175ede09481dd3c14cac26c] [formerly cf4dfe6c7ce811d489292a0896b4de46a89bfdc0 [formerly d16352b0ba2328ab521bbb6e5480a8c314f6ecb6]] Former-commit-id: bfa8e15160d458a77c9a1e5cea759d214716dbdd [formerly 74fa0134bc42399b0f3a6627791efed6f5176fa6] Former-commit-id: 04d04ac91ad7047afc541d5c43e69f81fae54f2a
This commit is contained in:
parent
d7c3665e2b
commit
59468830bb
|
@ -276,14 +276,20 @@ func search(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error)
|
||||||
scope = filepath.Clean(scope)
|
scope = filepath.Clean(scope)
|
||||||
|
|
||||||
err = filepath.Walk(scope, func(path string, f os.FileInfo, err error) error {
|
err = filepath.Walk(scope, func(path string, f os.FileInfo, err error) error {
|
||||||
if !search.CaseSensitive {
|
var (
|
||||||
path = strings.ToLower(path)
|
originalPath string
|
||||||
}
|
)
|
||||||
|
|
||||||
path = strings.TrimPrefix(path, scope)
|
path = strings.TrimPrefix(path, scope)
|
||||||
path = strings.TrimPrefix(path, "/")
|
path = strings.TrimPrefix(path, "/")
|
||||||
path = strings.Replace(path, "\\", "/", -1)
|
path = strings.Replace(path, "\\", "/", -1)
|
||||||
|
|
||||||
|
originalPath = path
|
||||||
|
|
||||||
|
if !search.CaseSensitive {
|
||||||
|
path = strings.ToLower(path)
|
||||||
|
}
|
||||||
|
|
||||||
// Only execute if there are conditions to meet.
|
// Only execute if there are conditions to meet.
|
||||||
if len(search.Conditions) > 0 {
|
if len(search.Conditions) > 0 {
|
||||||
match := false
|
match := false
|
||||||
|
@ -326,7 +332,7 @@ func search(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error)
|
||||||
|
|
||||||
response, _ := json.Marshal(map[string]interface{}{
|
response, _ := json.Marshal(map[string]interface{}{
|
||||||
"dir": f.IsDir(),
|
"dir": f.IsDir(),
|
||||||
"path": path,
|
"path": originalPath,
|
||||||
})
|
})
|
||||||
|
|
||||||
return conn.WriteMessage(websocket.TextMessage, response)
|
return conn.WriteMessage(websocket.TextMessage, response)
|
||||||
|
|
Loading…
Reference in New Issue