MCPcopy
hub / github.com/cli/cli / GistIDFromURL

Function GistIDFromURL

pkg/cmd/gist/shared/shared.go:80–95  ·  view source on GitHub ↗
(gistURL string)

Source from the content-addressed store, hash-verified

78}
79
80func GistIDFromURL(gistURL string) (string, error) {
81 u, err := url.Parse(gistURL)
82 if err == nil && strings.HasPrefix(u.Path, "/") {
83 split := strings.Split(u.Path, "/")
84
85 if len(split) > 2 {
86 return split[2], nil
87 }
88
89 if len(split) == 2 && split[1] != "" {
90 return split[1], nil
91 }
92 }
93
94 return "", fmt.Errorf("Invalid gist URL %s", u)
95}
96
97const maxPerPage = 100
98

Callers 5

deleteRunFunction · 0.92
viewRunFunction · 0.92
renameRunFunction · 0.92
editRunFunction · 0.92
Test_GetGistIDFromURLFunction · 0.85

Calls 1

ErrorfMethod · 0.65

Tested by 1

Test_GetGistIDFromURLFunction · 0.68