Returns the rewritten URL and true on a match, or ("", false) otherwise.
(u *url.URL)
| 244 | |
| 245 | // Returns the rewritten URL and true on a match, or ("", false) otherwise. |
| 246 | func rewriteAutomationsURL(u *url.URL) (string, bool) { |
| 247 | // Only rewrite github.com (not GHE) automations UI URLs. |
| 248 | if u.Host != "github.com" { |
| 249 | return "", false |
| 250 | } |
| 251 | // Path must be: /{owner}/{repo}/agents/automations/{id} |
| 252 | segments := strings.Split(strings.Trim(u.Path, "/"), "/") |
| 253 | if len(segments) != 5 || segments[2] != "agents" || segments[3] != "automations" { |
| 254 | return "", false |
| 255 | } |
| 256 | owner, repo, id := segments[0], segments[1], segments[4] |
| 257 | if owner == "" || repo == "" || id == "" { |
| 258 | return "", false |
| 259 | } |
| 260 | capiURL := fmt.Sprintf("https://%s/agents/repos/%s/%s/automations/%s", |
| 261 | constants.GitHubCopilotMCPDomain, owner, repo, id) |
| 262 | return capiURL, true |
| 263 | } |
| 264 | |
| 265 | func explicitHostForRepo(repoSlug string) string { |
| 266 | if repoHost := getGitHubHostForRepo(repoSlug); repoHost != getGitHubHost() { |
no outgoing calls