fix: escape query on search

This commit is contained in:
rramiachraf 2023-03-13 20:18:43 +01:00
parent b97a09da37
commit 7a5a8392c7

View File

@ -4,6 +4,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/http" "net/http"
"net/url"
) )
type response struct { type response struct {
@ -35,7 +36,7 @@ type renderVars struct {
func searchHandler(w http.ResponseWriter, r *http.Request) { func searchHandler(w http.ResponseWriter, r *http.Request) {
query := r.URL.Query().Get("q") query := r.URL.Query().Get("q")
url := fmt.Sprintf(`https://genius.com/api/search/multi?q=%s`, query) url := fmt.Sprintf(`https://genius.com/api/search/multi?q=%s`, url.QueryEscape(query))
res, err := sendRequest(url) res, err := sendRequest(url)
if err != nil { if err != nil {