mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 15:30:36 +01:00
This commit is contained in:
parent
558d6d41bb
commit
dc35391ceb
|
@ -25,5 +25,6 @@ func TestSubdomainRedirectWWW(t *testing.T) {
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
e.GET(test.path).Expect().Status(httptest.StatusOK).Body().Equal(test.response)
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -785,12 +785,11 @@ func (ctx *Context) Host() string {
|
||||||
|
|
||||||
// GetHost returns the host part of the current URI.
|
// GetHost returns the host part of the current URI.
|
||||||
func GetHost(r *http.Request) string {
|
func GetHost(r *http.Request) string {
|
||||||
if host := r.Host; host != "" {
|
// contains subdomain.
|
||||||
|
if host := r.URL.Host; host != "" {
|
||||||
return host
|
return host
|
||||||
}
|
}
|
||||||
|
return r.Host
|
||||||
// contains subdomain.
|
|
||||||
return r.URL.Host
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Subdomain returns the subdomain of this request, if any.
|
// Subdomain returns the subdomain of this request, if any.
|
||||||
|
|
|
@ -327,7 +327,7 @@ func canHandleSubdomain(ctx *context.Context, subdomain string) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
requestHost := ctx.Request().URL.Host
|
requestHost := ctx.Host()
|
||||||
if netutil.IsLoopbackSubdomain(requestHost) {
|
if netutil.IsLoopbackSubdomain(requestHost) {
|
||||||
// this fixes a bug when listening on
|
// this fixes a bug when listening on
|
||||||
// 127.0.0.1:8080 for example
|
// 127.0.0.1:8080 for example
|
||||||
|
|
Loading…
Reference in New Issue
Block a user