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

Function normalizeSecretSetAPIHost

pkg/cli/secret_set_command.go:135–161  ·  view source on GitHub ↗
(apiBase string)

Source from the content-addressed store, hash-verified

133}
134
135func normalizeSecretSetAPIHost(apiBase string) string {
136 raw := strings.TrimSpace(apiBase)
137 if raw == "" {
138 return ""
139 }
140
141 candidates := []string{raw}
142 if !strings.Contains(raw, "://") {
143 candidates = append(candidates, "https://"+raw)
144 }
145 for _, candidate := range candidates {
146 parsed, err := url.Parse(candidate)
147 if err != nil || parsed.Hostname() == "" {
148 continue
149 }
150 if parsed.Hostname() == "api.github.com" {
151 return "github.com"
152 }
153 return parsed.Hostname()
154 }
155
156 legacy := stringutil.ExtractDomainFromURL(raw)
157 if legacy == "api.github.com" {
158 return "github.com"
159 }
160 return legacy
161}
162
163func resolveSecretValueForSet(fromEnv, fromFlag string) (string, error) {
164 if fromEnv != "" {

Callers 1

secretSetClientOptionsFunction · 0.85

Calls 1

ExtractDomainFromURLFunction · 0.92

Tested by

no test coverage detected