From a6a37629084eff62f31f783155a3c3546ee5d698 Mon Sep 17 00:00:00 2001 From: Muhammed Efe Cetin Date: Tue, 21 Oct 2025 00:05:40 +0200 Subject: [PATCH] bug: fix redirectHandler fails for requests like region/ --- http.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/http.go b/http.go index 3e5ce09..9afc8b4 100644 --- a/http.go +++ b/http.go @@ -53,11 +53,15 @@ func (r *Redirector) redirectHandler(w http.ResponseWriter, req *http.Request) { // If the path has a prefix of region/NA, it will use specific regions instead // of the default geographical distance - if strings.HasPrefix(req.URL.Path, "/region") { + if strings.HasPrefix(req.URL.Path, "/region/") { parts := strings.Split(req.URL.Path, "/") + if len(parts) < 3 || parts[2] == "" { + http.Error(w, "Region not specified", http.StatusBadRequest) + return + } - // region = parts[2] - if mirrors, ok := r.regionMap[parts[2]]; ok { + region := parts[2] + if mirrors, ok := r.regionMap[region]; ok { choices := make([]randutil.Choice, len(mirrors)) for i, item := range mirrors {