Skip to content

Commit

Permalink
fixed subdomain matching for sub-sub-subdomain and so on, now return …
Browse files Browse the repository at this point in the history
…404 when subdomain is missing
  • Loading branch information
yusing committed Sep 24, 2024
1 parent f426dbc commit 99216ff
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/route/http_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ func ProxyHandler(w http.ResponseWriter, r *http.Request) {
}

func findMux(host string) (*http.ServeMux, E.NestedError) {
sd := strings.Split(host, ".")[0]
hostSplit := strings.Split(host, ".")
n := len(hostSplit)
if n <= 2 {
return nil, E.Missing("subdomain")
}
sd := strings.Join(hostSplit[:n-2], ".")
if r, ok := httpRoutes.Load(PT.Alias(sd)); ok {
return r.mux, nil
}
Expand Down

0 comments on commit 99216ff

Please sign in to comment.