fix search modifying in server

This commit is contained in:
Bel LaPointe
2022-02-09 16:51:29 -07:00
parent 9fe6381245
commit 7ee04bbe8e
2 changed files with 8 additions and 5 deletions

View File

@@ -281,10 +281,11 @@ func (server *Server) urlFileId(id []string) string {
if len(id) == 0 {
return ""
}
result := id[0]
for i := 1; i < len(id); i++ {
id[0] = strings.Join([]string{id[0], url.PathEscape(id[i])}, "/")
result = strings.Join([]string{result, url.PathEscape(id[i])}, "/")
}
return id[0]
return result
}
func (server *Server) fileId(r *http.Request) []string {
@@ -350,7 +351,7 @@ func (server *Server) apiV0SearchHandler(w http.ResponseWriter, r *http.Request)
result := []string{}
if err := tree.ForEach(func(id []string, leaf Leaf) error {
for _, pattern := range patterns {
if !pattern.MatchString(leaf.Content) && !pattern.MatchString(fmt.Sprint(id)) {
if !pattern.MatchString(leaf.Content) && !pattern.MatchString(leaf.Title) {
return nil
}
}