MCPcopy Create free account
hub / github.com/cli/cli / parseArtifactURL

Function parseArtifactURL

pkg/cmd/issue/artifact/shared/shared.go:172–191  ·  view source on GitHub ↗

parseArtifactURL reads an artifact URL into its repository, issue number and artifact number. Like an issue URL, it may be http, and its query and fragment are ignored: only those three are read from it, and requests go to the API.

(arg string)

Source from the content-addressed store, hash-verified

170// fragment are ignored: only those three are read from it, and requests go to
171// the API.
172func parseArtifactURL(arg string) (ghrepo.Interface, int, int, error) {
173 invalid := fmt.Errorf("invalid artifact URL: %q", arg)
174 u, err := url.Parse(arg)
175 if err != nil || (u.Scheme != "http" && u.Scheme != "https") || u.Hostname() == "" {
176 return nil, 0, 0, invalid
177 }
178 m := artifactURLPath.FindStringSubmatch(u.Path)
179 if m == nil {
180 return nil, 0, 0, invalid
181 }
182 issueNumber, err := strconv.Atoi(m[3])
183 if err != nil || issueNumber < 1 {
184 return nil, 0, 0, invalid
185 }
186 number, err := strconv.Atoi(m[4])
187 if err != nil || number < 1 {
188 return nil, 0, 0, invalid
189 }
190 return ghrepo.NewWithHost(m[1], m[2], u.Hostname()), issueNumber, number, nil
191}
192
193// appendNew appends number to numbers, refusing a number already there.
194func appendNew(numbers []int, number int) ([]int, error) {

Callers 1

parseArtifactURLsFunction · 0.85

Calls 2

NewWithHostFunction · 0.92
ErrorfMethod · 0.65

Tested by

no test coverage detected