You've already forked armbian-router
mirror of
https://github.com/armbian/armbian-router.git
synced 2026-01-06 10:37:03 -08:00
bug: fix redirectHandler fails for requests like region/
This commit is contained in:
committed by
M. Efe Çetin
parent
9fdafef242
commit
a6a3762908
10
http.go
10
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 {
|
||||
|
||||
Reference in New Issue
Block a user