MCPcopy Create free account
hub / github.com/github/gh-aw / NormalizeGitHubHostURL

Function NormalizeGitHubHostURL

pkg/stringutil/urls.go:14–24  ·  view source on GitHub ↗

NormalizeGitHubHostURL ensures the host URL has a scheme (defaulting to https://) and no trailing slashes. It is safe to call with URLs that already have an http:// or https:// scheme.

(rawHostURL string)

Source from the content-addressed store, hash-verified

12// NormalizeGitHubHostURL ensures the host URL has a scheme (defaulting to https://) and no trailing slashes.
13// It is safe to call with URLs that already have an http:// or https:// scheme.
14func NormalizeGitHubHostURL(rawHostURL string) string {
15 // Remove all trailing slashes
16 normalized := strings.TrimRight(rawHostURL, "/")
17
18 // Add https:// scheme if no scheme is present
19 if !strings.HasPrefix(normalized, "https://") && !strings.HasPrefix(normalized, "http://") {
20 normalized = "https://" + normalized
21 }
22
23 return normalized
24}
25
26// ExtractDomainFromURL extracts the domain name from a URL string.
27// Handles various URL formats including full URLs with protocols, URLs with ports,

Calls

no outgoing calls