MCPcopy Index your code
hub / github.com/coder/coder / deriveWebBaseURL

Function deriveWebBaseURL

coderd/externalauth/gitprovider/github.go:77–92  ·  view source on GitHub ↗

deriveWebBaseURL converts a GitHub API base URL to the corresponding web base URL. github.com: https://api.github.com → https://github.com GHE: https://ghes.corp.com/api/v3 → https://ghes.corp.com

(apiBaseURL string)

Source from the content-addressed store, hash-verified

75// github.com: https://api.github.com → https://github.com
76// GHE: https://ghes.corp.com/api/v3 → https://ghes.corp.com
77func deriveWebBaseURL(apiBaseURL string) string {
78 u, err := url.Parse(apiBaseURL)
79 if err != nil {
80 return "https://github.com"
81 }
82
83 // Standard github.com: API host is api.github.com.
84 if strings.EqualFold(u.Host, "api.github.com") {
85 return "https://github.com"
86 }
87
88 // GHE: strip /api/v3 path suffix.
89 u.Path = strings.TrimSuffix(u.Path, "/api/v3")
90 u.Path = strings.TrimSuffix(u.Path, "/")
91 return u.String()
92}
93
94// extractHost returns the host portion of a URL.
95func extractHost(rawURL string) string {

Callers 1

newGitHubFunction · 0.85

Calls 2

ParseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected