refactor index handling of empty queries

pull/4/head
cblgh 2021-04-25 18:48:34 +02:00
rodzic 180fb9663d
commit 9ffff1dc1a
1 zmienionych plików z 6 dodań i 9 usunięć

Wyświetl plik

@ -49,15 +49,12 @@ func (h RequestHandler) searchRoute(res http.ResponseWriter, req *http.Request)
if req.Method == http.MethodGet {
params := req.URL.Query()
words, exists := params["q"]
if !exists || words[0] == "" {
var empty interface{}
err := indexView.Execute(res, empty)
util.Check(err)
return
}
query = words[0]
} else {
if words, exists := params["q"]; exists && words[0] != "" {
query = words[0]
}
}
if len(query) == 0 {
var empty interface{}
err := indexView.Execute(res, empty)
util.Check(err)