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

Function GistIDFromURL

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

Source from the content-addressed store, hash-verified

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

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