From 96219442f57838324e9d9efff701669b6ca97142 Mon Sep 17 00:00:00 2001 From: imp2002 Date: Tue, 18 Apr 2023 21:30:46 +0800 Subject: [PATCH] feat: fix Tencent Cloud OSS storage connect incorrect issue (#1752) * fix: fix Tencent Cloud OSS storage connect incorrect * Update provider.go --------- Co-authored-by: hsluoyz --- object/provider.go | 7 +++++++ util/string.go | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/object/provider.go b/object/provider.go index cdd99278..d1cc45a6 100644 --- a/object/provider.go +++ b/object/provider.go @@ -221,6 +221,10 @@ func UpdateProvider(id string, provider *Provider) bool { if provider.ClientSecret2 == "***" { session = session.Omit("client_secret2") } + + provider.Endpoint = util.GetEndPoint(provider.Endpoint) + provider.IntranetEndpoint = util.GetEndPoint(provider.IntranetEndpoint) + affected, err := session.Update(provider) if err != nil { panic(err) @@ -230,6 +234,9 @@ func UpdateProvider(id string, provider *Provider) bool { } func AddProvider(provider *Provider) bool { + provider.Endpoint = util.GetEndPoint(provider.Endpoint) + provider.IntranetEndpoint = util.GetEndPoint(provider.IntranetEndpoint) + affected, err := adapter.Engine.Insert(provider) if err != nil { panic(err) diff --git a/util/string.go b/util/string.go index 22e4541f..d5409f47 100644 --- a/util/string.go +++ b/util/string.go @@ -259,3 +259,11 @@ func maskString(str string) string { return fmt.Sprintf("%c%s%c", str[0], strings.Repeat("*", len(str)-2), str[len(str)-1]) } } + +// GetEndPoint remove scheme from url +func GetEndPoint(endpoint string) string { + for _, prefix := range []string{"https://", "http://"} { + endpoint = strings.TrimPrefix(endpoint, prefix) + } + return endpoint +}