From 8628faaec7b32a5df134377e9b7c179b9278a8a2 Mon Sep 17 00:00:00 2001 From: KincaidYang <91786638+KincaidYang@users.noreply.github.com> Date: Wed, 24 Jan 2024 10:12:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E9=80=BB=E8=BE=91=E6=97=B6=EF=BC=8C=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=20TLD=20=E5=90=8E=E7=BC=80=E6=8F=90=E5=8F=96=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=A4=B1=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.go b/main.go index 4b687af..0cf68fc 100644 --- a/main.go +++ b/main.go @@ -288,6 +288,12 @@ func handler(w http.ResponseWriter, r *http.Request) { domain = mainDomain // 如果结果不符合预期(例如 "com.cn"),则从右向左读取域名,将第一个点右边的部分作为 TLD + if strings.Contains(tld, ".") { + parts := strings.Split(mainDomain, ".") + tld = parts[len(parts)-1] + } + + // Cache cacheKeyPrefix := "whois:" key := fmt.Sprintf("%s%s", cacheKeyPrefix, domain) cacheResult, err := redisClient.Get(ctx, key).Result()