ResourceHost returns the host to send subscription requests for resourceURL to, or fallback when the URL names no host. The API validates the resource; its host only picks where to send the request.
(resourceURL, fallback string)
| 14 | // ResourceHost returns the host to send subscription requests for resourceURL to, or fallback when the URL names no |
| 15 | // host. The API validates the resource; its host only picks where to send the request. |
| 16 | func ResourceHost(resourceURL, fallback string) string { |
| 17 | if u, err := url.Parse(resourceURL); err == nil && u.Host != "" { |
| 18 | return ghauth.NormalizeHostname(u.Hostname()) |
| 19 | } |
| 20 | return fallback |
| 21 | } |
| 22 | |
| 23 | // NormalizeEventTypes drops blank and duplicate event types, which the API rejects. |
| 24 | func NormalizeEventTypes(names []string) []string { |