Fix off-by-one error

This commit is contained in:
Alan Bernstein 2020-04-08 22:58:45 -05:00 committed by Matt Jaffee
parent e3ace544ca
commit 5aebb242f8
No known key found for this signature in database
GPG key ID: 08A3DFFF987B11BF

View file

@ -218,7 +218,7 @@ const (
func (h *Handler) addQueryContext(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
pathParts := strings.Split(r.URL.Path, "/")
if len(pathParts) >= 3 && pathParts[3] == "query" {
if len(pathParts) > 3 && pathParts[3] == "query" {
req, err := h.readQueryRequest(r)
ctx := context.WithValue(r.Context(), contextKeyQueryRequest, req)
ctx = context.WithValue(ctx, contextKeyQueryError, err)