fix: search case sensitiveness (#515)
parent
3372f0546d
commit
d16352b0ba
|
@ -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