diff --git a/context/context.go b/context/context.go index 09fbf3e5..1619812e 100644 --- a/context/context.go +++ b/context/context.go @@ -910,7 +910,6 @@ func GetDomain(hostport string) string { host = tmp } - // has port. switch host { case "127.0.0.1", "0.0.0.0", "::1", "[::1]", "0:0:0:0:0:0:0:0", "0:0:0:0:0:0:0:1": // loopback. diff --git a/core/netutil/addr.go b/core/netutil/addr.go index 8419cb14..78ce80c6 100644 --- a/core/netutil/addr.go +++ b/core/netutil/addr.go @@ -38,12 +38,11 @@ var IsLoopbackSubdomain = func(s string) bool { // GetLoopbackSubdomain returns the part of the loopback subdomain. func GetLoopbackSubdomain(s string) string { if strings.HasPrefix(s, "127.0.0.1:") || s == "127.0.0.1" || - strings.HasPrefix(s, "0.0.0.0:") || s == "0.0.0.0" /* let's resolve that without regex (see below)*/ { + strings.HasPrefix(s, "0.0.0.0:") || s == "0.0.0.0" { return s } - ss := loopbackSubRegex.FindString(s) - return ss + return loopbackSubRegex.FindString(s) } // IsLoopbackHost tries to catch the local addresses when a developer diff --git a/core/router/router_subdomain_redirect_wrapper.go b/core/router/router_subdomain_redirect_wrapper.go index 65b4c76e..a6ea31b8 100644 --- a/core/router/router_subdomain_redirect_wrapper.go +++ b/core/router/router_subdomain_redirect_wrapper.go @@ -115,7 +115,7 @@ func (s *subdomainRedirectWrapper) Wrapper(w http.ResponseWriter, r *http.Reques if loopback := netutil.GetLoopbackSubdomain(root); loopback != "" { root = strings.Replace(root, loopback, context.GetDomain(host), 1) } - // println("root: " + root) + hasSubdomain := host != root if !hasSubdomain && !s.isFromRoot {