From c32dd0d95c27e30d1633010dbbda186a2b4654bc Mon Sep 17 00:00:00 2001 From: "Gerasimos (Makis) Maropoulos" Date: Sat, 30 May 2020 20:25:37 +0300 Subject: [PATCH] fix #1524 Former-commit-id: a166bf3be97f6cc8a2ab4a8890881c258c4729d6 --- context/context.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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)