MCPcopy Create free account
hub / github.com/gogs/gogs / HandleMirrorCredentials

Function HandleMirrorCredentials

internal/database/mirror.go:107–120  ·  view source on GitHub ↗

HandleMirrorCredentials replaces user credentials from HTTP/HTTPS URL with placeholder . It returns original string if protocol is not HTTP/HTTPS. TODO(unknwon): Use url.Parse.

(url string, mosaics bool)

Source from the content-addressed store, hash-verified

105// It returns original string if protocol is not HTTP/HTTPS.
106// TODO(unknwon): Use url.Parse.
107func HandleMirrorCredentials(url string, mosaics bool) string {
108 i := strings.Index(url, "@")
109 if i == -1 {
110 return url
111 }
112 start := strings.Index(url, "://")
113 if start == -1 {
114 return url
115 }
116 if mosaics {
117 return url[:start+3] + "<credentials>" + url[i:]
118 }
119 return url[:start+3] + url[i+1:]
120}
121
122// Address returns mirror address from Git repository config without credentials.
123func (m *Mirror) Address() string {

Callers 4

MigratePostFunction · 0.92
MigrateFunction · 0.92
AddressMethod · 0.85
MosaicsAddressMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected