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)
| 105 | // It returns original string if protocol is not HTTP/HTTPS. |
| 106 | // TODO(unknwon): Use url.Parse. |
| 107 | func 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. |
| 123 | func (m *Mirror) Address() string { |
no outgoing calls
no test coverage detected