diff --git a/context/context.go b/context/context.go index ddb650a4..be200008 100644 --- a/context/context.go +++ b/context/context.go @@ -1947,11 +1947,16 @@ func (ctx *context) GetDomain() string { host = host[0:portIdx] } - if domain, err := publicsuffix.EffectiveTLDPlusOne(host); err == nil { - host = domain - } + 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:1": + return "localhost" + default: + if domain, err := publicsuffix.EffectiveTLDPlusOne(host); err == nil { + host = domain + } - return host + return host + } } // IsAjax returns true if this request is an 'ajax request'( XMLHttpRequest)