From c766140dad3408048ad843d0e7b4ab5d9f5777c6 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Sat, 16 Sep 2023 18:03:02 +0200 Subject: Add `RemoteAddress` to mirrors (#26952) This PR adds a new field `RemoteAddress` to both mirror types which contains the sanitized remote address for easier (database) access to that information. Will be used in the audit PR if merged. --- modules/util/url.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'modules/util/url.go') diff --git a/modules/util/url.go b/modules/util/url.go index 75fcf634a9..62370339c8 100644 --- a/modules/util/url.go +++ b/modules/util/url.go @@ -39,3 +39,12 @@ func URLJoin(base string, elems ...string) string { } return joinedURL } + +func SanitizeURL(s string) (string, error) { + u, err := url.Parse(s) + if err != nil { + return "", err + } + u.User = nil + return u.String(), nil +} -- cgit v1.2.3