NormalizeGitHubHostURL ensures the host URL has a scheme (defaulting to https://) and no trailing slashes. It is safe to call with URLs that already have an http:// or https:// scheme.
(rawHostURL string)
| 12 | // NormalizeGitHubHostURL ensures the host URL has a scheme (defaulting to https://) and no trailing slashes. |
| 13 | // It is safe to call with URLs that already have an http:// or https:// scheme. |
| 14 | func NormalizeGitHubHostURL(rawHostURL string) string { |
| 15 | // Remove all trailing slashes |
| 16 | normalized := strings.TrimRight(rawHostURL, "/") |
| 17 | |
| 18 | // Add https:// scheme if no scheme is present |
| 19 | if !strings.HasPrefix(normalized, "https://") && !strings.HasPrefix(normalized, "http://") { |
| 20 | normalized = "https://" + normalized |
| 21 | } |
| 22 | |
| 23 | return normalized |
| 24 | } |
| 25 | |
| 26 | // ExtractDomainFromURL extracts the domain name from a URL string. |
| 27 | // Handles various URL formats including full URLs with protocols, URLs with ports, |
no outgoing calls