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

Function normalizeDocURL

tools/metadata/metadata.go:488–510  ·  view source on GitHub ↗

normalizeDocURL cleans docURL's path and enforces metadataDocsAPIVersion for https://docs.github.com/rest and https://docs.github.com/enterprise-cloud@latest/rest URLs.

(docURL string)

Source from the content-addressed store, hash-verified

486// https://docs.github.com/rest and
487// https://docs.github.com/enterprise-cloud@latest/rest URLs.
488func normalizeDocURL(docURL string) string {
489 u, err := url.Parse(docURL)
490 if err != nil {
491 return docURL
492 }
493 cleanPath := path.Clean(u.Path)
494 isRESTDocsURL := u.Host == "docs.github.com" &&
495 (cleanPath == "/rest" ||
496 strings.HasPrefix(cleanPath, "/rest/") ||
497 cleanPath == "/enterprise-cloud@latest/rest" ||
498 strings.HasPrefix(cleanPath, "/enterprise-cloud@latest/rest/"))
499 if !isRESTDocsURL {
500 return docURL
501 }
502
503 u.Path = cleanPath
504 q := u.Query()
505 if q.Get("apiVersion") == "" {
506 q.Set("apiVersion", metadataDocsAPIVersion)
507 }
508 u.RawQuery = q.Encode()
509 return u.String()
510}
511
512// nodeServiceMethod returns the name of the service method represented by fn, or "" if fn is not a service method.
513// Name is in the form of "Receiver.Function", for example "IssuesService.Create".

Callers 2

updateDocsVisitorFunction · 0.85
Test_normalizeDocURLFunction · 0.85

Calls 2

GetMethod · 0.45
StringMethod · 0.45

Tested by 1

Test_normalizeDocURLFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…