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

Function extractDomainFallback

pkg/stringutil/urls.go:62–76  ·  view source on GitHub ↗

extractDomainFallback extracts domain using string manipulation. This handles URLs without protocols, CONNECT requests (domain:port format), and plain domain names.

(urlStr string)

Source from the content-addressed store, hash-verified

60// This handles URLs without protocols, CONNECT requests (domain:port format),
61// and plain domain names.
62func extractDomainFallback(urlStr string) string {
63 // Remove protocol if present (in case it wasn't http/https)
64 urlStr = strings.TrimPrefix(urlStr, "https://")
65 urlStr = strings.TrimPrefix(urlStr, "http://")
66
67 // Remove port and path
68 if idx := strings.Index(urlStr, ":"); idx != -1 {
69 urlStr = urlStr[:idx]
70 }
71 if idx := strings.Index(urlStr, "/"); idx != -1 {
72 urlStr = urlStr[:idx]
73 }
74
75 return strings.TrimSpace(urlStr)
76}

Callers 1

ExtractDomainFromURLFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected