implement #88 on back-end
Former-commit-id: 95c30bbefe3f97cbccc49b7e8d60ad20cee5d82f [formerly b8574b97cd6ffee5e3f473a10f7a97448d59f853] [formerly 133725ae36fdf64b270f9f5761a26e480f3ff189 [formerly de480c25bb4c77a7b9aa476a3e3a8a9e898d43f6]] Former-commit-id: bd3547c5afb9420d29a54b21907d74d8f1c53164 [formerly 12676ba6a477473683255d9d1da445215d98ff38] Former-commit-id: 2ccfbe9adb08aac188c90fe2ef8b47f659c3f4a8
This commit is contained in:
parent
085439d57e
commit
4cb3ff6ff2
|
@ -24,6 +24,8 @@ func Search(w http.ResponseWriter, r *http.Request, c *config.Config, u *config.
|
||||||
message []byte
|
message []byte
|
||||||
)
|
)
|
||||||
|
|
||||||
|
caseInsensitive := (r.URL.Query().Get("insensitive") == "true")
|
||||||
|
|
||||||
// Starts an infinite loop until a valid command is captured.
|
// Starts an infinite loop until a valid command is captured.
|
||||||
for {
|
for {
|
||||||
_, message, err = conn.ReadMessage()
|
_, message, err = conn.ReadMessage()
|
||||||
|
@ -37,6 +39,10 @@ func Search(w http.ResponseWriter, r *http.Request, c *config.Config, u *config.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if caseInsensitive {
|
||||||
|
search = strings.ToLower(search)
|
||||||
|
}
|
||||||
|
|
||||||
scope := strings.Replace(r.URL.Path, c.BaseURL, "", 1)
|
scope := strings.Replace(r.URL.Path, c.BaseURL, "", 1)
|
||||||
scope = strings.TrimPrefix(scope, "/")
|
scope = strings.TrimPrefix(scope, "/")
|
||||||
scope = "/" + scope
|
scope = "/" + scope
|
||||||
|
@ -45,6 +51,10 @@ func Search(w http.ResponseWriter, r *http.Request, c *config.Config, u *config.
|
||||||
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 caseInsensitive {
|
||||||
|
path = strings.ToLower(path)
|
||||||
|
}
|
||||||
|
|
||||||
if strings.Contains(path, search) {
|
if strings.Contains(path, search) {
|
||||||
if !u.Allowed(path) {
|
if !u.Allowed(path) {
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue