mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-12 15:33:39 +02:00
Fix #37564: Rename to StripURL - lint review
This commit is contained in:
parent
4646e0bc3f
commit
a093b0b5a3
@ -27,7 +27,7 @@ func SanitizeURL(s string) (string, error) {
|
||||
return u.String(), nil
|
||||
}
|
||||
|
||||
// StripUrl returns the scheme, host, and path portions of s with userinfo,
|
||||
// StripURL returns the scheme, host, and path portions of s with userinfo,
|
||||
// query string, and fragment removed. Intended for logging URLs whose
|
||||
// userinfo or query string may carry credentials (e.g. https://user:pass@…
|
||||
// or signed S3/GCS/Cloudinary URLs whose signatures live in the query
|
||||
@ -35,8 +35,8 @@ func SanitizeURL(s string) (string, error) {
|
||||
//
|
||||
// Unlike SanitizeURL (which only strips userinfo and is used by callers
|
||||
// such as mirroring/indexing/migrations that still need the query string
|
||||
// to actually use the URL), StripUrl is for logging only.
|
||||
func StripUrl(s string) string {
|
||||
// to actually use the URL), StripURL is for logging only.
|
||||
func StripURL(s string) string {
|
||||
u, err := url.Parse(s)
|
||||
if err != nil {
|
||||
return "<unparseable url>"
|
||||
|
||||
@ -9,7 +9,7 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestStripUrl(t *testing.T) {
|
||||
func TestStripURL(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
in string
|
||||
@ -54,7 +54,7 @@ func TestStripUrl(t *testing.T) {
|
||||
}
|
||||
for _, c := range cases {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
assert.Equal(t, c.want, StripUrl(c.in))
|
||||
assert.Equal(t, c.want, StripURL(c.in))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -308,7 +308,7 @@ func oauth2UpdateAvatarIfNeed(ctx *context.Context, rawURL string, u *user_model
|
||||
}
|
||||
// Compute a redacted URL for log lines BEFORE issuing the request, so we
|
||||
// never accidentally log signed-URL query parameters or userinfo.
|
||||
logURL := util.StripUrl(rawURL)
|
||||
logURL := util.StripURL(rawURL)
|
||||
|
||||
// Bind the outbound fetch to the inbound request context so the download
|
||||
// is cancelled if the user navigates away / aborts login, and so any
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user