cmd/pkgserver: finish search implementation

This commit is contained in:
mae
2026-04-18 02:07:52 -05:00
parent ba17f9d4f3
commit 004ac511a9
14 changed files with 411 additions and 206 deletions

View File

@@ -127,7 +127,7 @@ func (index *packageIndex) handleSearch(w http.ResponseWriter, r *http.Request)
)
return
}
search, err := url.PathUnescape(q.Get("search"))
search, err := url.QueryUnescape(q.Get("search"))
if len(search) > 100 || err != nil {
http.Error(
w, "search must be a string between 0 and 100 characters long",
@@ -141,8 +141,8 @@ func (index *packageIndex) handleSearch(w http.ResponseWriter, r *http.Request)
http.Error(w, err.Error(), http.StatusInternalServerError)
}
writeAPIPayload(w, &struct {
Count int `json:"count"`
Results []searchResult `json:"results"`
Count int `json:"count"`
Values []searchResult `json:"values"`
}{n, res})
}