MCPcopy Index your code
hub / github.com/google/go-github / parseURL

Function parseURL

github/url.go:18–33  ·  view source on GitHub ↗

parseURL parses the given string as a URL and ensures that the path ends with a slash. If the input string is empty, it returns an error. If the URL cannot be parsed, it returns the parsing error.

(s string)

Source from the content-addressed store, hash-verified

16// with a slash. If the input string is empty, it returns an error. If the URL
17// cannot be parsed, it returns the parsing error.
18func parseURL(s string) (*url.URL, error) {
19 if s == "" {
20 return nil, errors.New("url cannot be empty")
21 }
22
23 u, err := url.Parse(s)
24 if err != nil {
25 return nil, fmt.Errorf("invalid url: %w", err)
26 }
27
28 if !strings.HasSuffix(u.Path, "/") {
29 u.Path += "/"
30 }
31
32 return u, nil
33}

Callers 3

Test_parseURLFunction · 0.85
WithURLsFunction · 0.85
WithEnterpriseURLsFunction · 0.85

Calls

no outgoing calls

Tested by 1

Test_parseURLFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…