mirror of
https://github.com/kataras/iris.git
synced 2025-12-24 05:17:03 +00:00
fix SubdomainRedirect on loopbacks
fix: https://github.com/kataras/iris/issues/1584#issuecomment-674001454
This commit is contained in:
@@ -21,7 +21,8 @@ func init() {
|
||||
|
||||
// IsLoopbackSubdomain checks if a string is a subdomain or a hostname.
|
||||
var IsLoopbackSubdomain = func(s string) bool {
|
||||
if strings.HasPrefix(s, "127.0.0.1:") || s == "127.0.0.1" {
|
||||
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)*/ {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -34,6 +35,17 @@ var IsLoopbackSubdomain = func(s string) bool {
|
||||
return valid
|
||||
}
|
||||
|
||||
// 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)*/ {
|
||||
return s
|
||||
}
|
||||
|
||||
ss := loopbackSubRegex.FindString(s)
|
||||
return ss
|
||||
}
|
||||
|
||||
// IsLoopbackHost tries to catch the local addresses when a developer
|
||||
// navigates to a subdomain that its hostname differs from Application.Config.Addr.
|
||||
// Developer may want to override this function to return always false
|
||||
|
||||
Reference in New Issue
Block a user