From 12bfe87c43f963691324fd43d9407510c243833c Mon Sep 17 00:00:00 2001 From: CareyWong Date: Wed, 12 Feb 2020 18:26:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=B7=E6=B1=82=E9=95=BF?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E7=BC=96=E7=A0=81=E6=96=B9=E5=BC=8F=E4=B8=BA?= =?UTF-8?q?=20base64=20encode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 +++- main.go | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index d163863..47bde7b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -build/ \ No newline at end of file +build/ + +.idea/ \ No newline at end of file diff --git a/main.go b/main.go index 3440c9c..1242983 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "bytes" + "encoding/base64" "encoding/json" "flag" "fmt" @@ -9,7 +10,6 @@ import ( "github.com/go-redis/redis/v7" "io/ioutil" "net/http" - "net/url" "time" ) @@ -68,7 +68,8 @@ func main() { return } - longUrl, err := url.QueryUnescape(longUrl) + _longUrl, _ := base64.StdEncoding.DecodeString(longUrl) + longUrl = string(_longUrl) res.LongUrl = longUrl // 先查缓存