Gerasimos (Makis) Maropoulos 2020-08-14 13:04:48 +03:00
parent 558d6d41bb
commit dc35391ceb
No known key found for this signature in database
GPG Key ID: 5DBE766BD26A54E7
3 changed files with 5 additions and 5 deletions

View File

@ -25,5 +25,6 @@ func TestSubdomainRedirectWWW(t *testing.T) {
for _, test := range tests {
e.GET(test.path).Expect().Status(httptest.StatusOK).Body().Equal(test.response)
e.GET(test.path).WithURL("www.mydomain.com").Expect().Status(httptest.StatusOK).Body().Equal(test.response)
}
}

View File

@ -785,12 +785,11 @@ func (ctx *Context) Host() string {
// GetHost returns the host part of the current URI.
func GetHost(r *http.Request) string {
if host := r.Host; host != "" {
// contains subdomain.
if host := r.URL.Host; host != "" {
return host
}
// contains subdomain.
return r.URL.Host
return r.Host
}
// Subdomain returns the subdomain of this request, if any.

View File

@ -327,7 +327,7 @@ func canHandleSubdomain(ctx *context.Context, subdomain string) bool {
return true
}
requestHost := ctx.Request().URL.Host
requestHost := ctx.Host()
if netutil.IsLoopbackSubdomain(requestHost) {
// this fixes a bug when listening on
// 127.0.0.1:8080 for example