MCPcopy
hub / github.com/github/github-mcp-server / parseAPIHost

Function parseAPIHost

pkg/utils/api.go:224–247  ·  view source on GitHub ↗

Note that this does not handle ports yet, so development environments are out.

(s string)

Source from the content-addressed store, hash-verified

222
223// Note that this does not handle ports yet, so development environments are out.
224func parseAPIHost(s string) (APIHost, error) {
225 if s == "" {
226 return newDotcomHost()
227 }
228
229 u, err := url.Parse(s)
230 if err != nil {
231 return APIHost{}, fmt.Errorf("could not parse host as URL: %s", s)
232 }
233
234 if u.Scheme == "" {
235 return APIHost{}, fmt.Errorf("host must have a scheme (http or https): %s", s)
236 }
237
238 if u.Hostname() == "github.com" || strings.HasSuffix(u.Hostname(), ".github.com") {
239 return newDotcomHost()
240 }
241
242 if u.Hostname() == "ghe.com" || strings.HasSuffix(u.Hostname(), ".ghe.com") {
243 return newGHECHost(s)
244 }
245
246 return newGHESHost(s)
247}

Callers 2

NewAPIHostFunction · 0.85
TestParseAPIHostFunction · 0.85

Calls 3

newDotcomHostFunction · 0.85
newGHECHostFunction · 0.85
newGHESHostFunction · 0.85

Tested by 1

TestParseAPIHostFunction · 0.68