diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2023-09-16 18:03:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-16 16:03:02 +0000 |
commit | c766140dad3408048ad843d0e7b4ab5d9f5777c6 (patch) | |
tree | 49cd37606ae0cb252cd16264c111c3cf5b00088d /modules/util/url.go | |
parent | 5e039b05801a2ceeb29b23c657110af02834b57e (diff) | |
download | gitea-c766140dad3408048ad843d0e7b4ab5d9f5777c6.tar.gz gitea-c766140dad3408048ad843d0e7b4ab5d9f5777c6.zip |
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.
Diffstat (limited to 'modules/util/url.go')
-rw-r--r-- | modules/util/url.go | 9 |
1 files changed, 9 insertions, 0 deletions
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 +} |