From 4652d752b609d38ac271c66e6b4bd2ddbbbbdbc8 Mon Sep 17 00:00:00 2001 From: "rongfu.leng" <1275177125@qq.com> Date: Mon, 29 May 2023 16:37:51 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90optimization=E3=80=91Use=20URL.Redacte?= =?UTF-8?q?d=20method=20repleace=20redacted=20(#18716)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit use URL.Redacted method replease redacted Signed-off-by: lengrongfu <1275177125@qq.com> --- src/lib/cache/cache.go | 2 +- src/lib/cache/util.go | 14 -------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/src/lib/cache/cache.go b/src/lib/cache/cache.go index 116fa4f59..aa23efaaa 100644 --- a/src/lib/cache/cache.go +++ b/src/lib/cache/cache.go @@ -103,7 +103,7 @@ func Initialize(typ, addr string) error { redactedAddr := addr if u, err := url.Parse(addr); err == nil { - redactedAddr = redacted(u) + redactedAddr = u.Redacted() } options := []retry.Option{ diff --git a/src/lib/cache/util.go b/src/lib/cache/util.go index 237bf4785..412bfde51 100644 --- a/src/lib/cache/util.go +++ b/src/lib/cache/util.go @@ -15,23 +15,9 @@ package cache import ( - "net/url" "sync" ) -// TODO: use the URL.Redacted when golang upgrade to 1.15 -func redacted(u *url.URL) string { - if u == nil { - return "" - } - - ru := *u - if _, has := ru.User.Password(); has { - ru.User = url.UserPassword(ru.User.Username(), "xxxxx") - } - return ru.String() -} - type keyMutex struct { m *sync.Map }