MCPcopy Create free account
hub / github.com/github/gh-aw / rewriteAutomationsURL

Function rewriteAutomationsURL

pkg/cli/spec.go:246–263  ·  view source on GitHub ↗

Returns the rewritten URL and true on a match, or ("", false) otherwise.

(u *url.URL)

Source from the content-addressed store, hash-verified

244
245// Returns the rewritten URL and true on a match, or ("", false) otherwise.
246func 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
265func explicitHostForRepo(repoSlug string) string {
266 if repoHost := getGitHubHostForRepo(repoSlug); repoHost != getGitHubHost() {

Callers 2

parseWorkflowSpecFunction · 0.85

Calls

no outgoing calls

Tested by 1