Skip to content

Commit d16352b

Browse files
hugomassing1138-4EB
authored andcommitted
fix: search case sensitiveness (filebrowser#515)
1 parent 3372f05 commit d16352b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/http/websockets.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,20 @@ func search(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error)
276276
scope = filepath.Clean(scope)
277277

278278
err = filepath.Walk(scope, func(path string, f os.FileInfo, err error) error {
279-
if !search.CaseSensitive {
280-
path = strings.ToLower(path)
281-
}
279+
var (
280+
originalPath string
281+
)
282282

283283
path = strings.TrimPrefix(path, scope)
284284
path = strings.TrimPrefix(path, "/")
285285
path = strings.Replace(path, "\\", "/", -1)
286286

287+
originalPath = path
288+
289+
if !search.CaseSensitive {
290+
path = strings.ToLower(path)
291+
}
292+
287293
// Only execute if there are conditions to meet.
288294
if len(search.Conditions) > 0 {
289295
match := false
@@ -326,7 +332,7 @@ func search(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error)
326332

327333
response, _ := json.Marshal(map[string]interface{}{
328334
"dir": f.IsDir(),
329-
"path": path,
335+
"path": originalPath,
330336
})
331337

332338
return conn.WriteMessage(websocket.TextMessage, response)

0 commit comments

Comments
 (0)