Skip to content

Commit

Permalink
fix: search case sensitiveness (filebrowser#515)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomassing authored and 1138-4EB committed Aug 22, 2018
1 parent 3372f05 commit d16352b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/http/websockets.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,20 @@ func search(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error)
scope = filepath.Clean(scope)

err = filepath.Walk(scope, func(path string, f os.FileInfo, err error) error {
if !search.CaseSensitive {
path = strings.ToLower(path)
}
var (
originalPath string
)

path = strings.TrimPrefix(path, scope)
path = strings.TrimPrefix(path, "/")
path = strings.Replace(path, "\\", "/", -1)

originalPath = path

if !search.CaseSensitive {
path = strings.ToLower(path)
}

// Only execute if there are conditions to meet.
if len(search.Conditions) > 0 {
match := false
Expand Down Expand Up @@ -326,7 +332,7 @@ func search(c *fb.Context, w http.ResponseWriter, r *http.Request) (int, error)

response, _ := json.Marshal(map[string]interface{}{
"dir": f.IsDir(),
"path": path,
"path": originalPath,
})

return conn.WriteMessage(websocket.TextMessage, response)
Expand Down

0 comments on commit d16352b

Please sign in to comment.