fix search issue

Former-commit-id: 6fcb2017aba409c3ec9480f9ea894702eee1be01 [formerly a9c45f3c83ed22a6852e4f7d2fef6155e4a05b26] [formerly bc5dc0641dad6309f33564d8969a42e4dbc37df9 [formerly ac7c4db4e14c17993b038813893acca1234275cb]]
Former-commit-id: 4669eafeb0872c2b66183b1c78a2de756b58ca3b [formerly 75efe1c23c13cb34d8aaf1e14b70d9830be16023]
Former-commit-id: 5fcc16ffee3df50f302940dab3497be71be7f81f
This commit is contained in:
Henrique Dias 2017-05-27 08:34:09 +01:00
parent eb86ce27f6
commit 3d6e3ed2e5
2 changed files with 14 additions and 9 deletions

View File

@ -149,7 +149,7 @@ FileManager allows you to search through your files and it has some options. By
this are keywords this are keywords
``` ```
If you search for that it will look at every file that contains "this", "are" and "keywords" on their name. If you want to search for an exact term, you should surround your search by double quotes: If you search for that it will look at every file that contains "this", "are" or "keywords" on their name. If you want to search for an exact term, you should surround your search by double quotes:
``` ```
"this is the name" "this is the name"

View File

@ -85,24 +85,29 @@ func Search(w http.ResponseWriter, r *http.Request, c *config.Config, u *config.
} }
path = strings.Replace(path, "\\", "/", -1) path = strings.Replace(path, "\\", "/", -1)
is := false
for _, term := range search.Terms { for _, term := range search.Terms {
if is {
break
}
if strings.Contains(path, term) { if strings.Contains(path, term) {
if !u.Allowed(path) { if !u.Allowed(path) {
return nil return nil
} }
path = strings.TrimPrefix(path, scope) is = true
path = strings.TrimPrefix(path, "/")
err = conn.WriteMessage(websocket.TextMessage, []byte(path))
if err != nil {
return err
}
} }
} }
return nil if !is {
return nil
}
path = strings.TrimPrefix(path, scope)
path = strings.TrimPrefix(path, "/")
return conn.WriteMessage(websocket.TextMessage, []byte(path))
}) })
if err != nil { if err != nil {