extractDomainFallback extracts domain using string manipulation. This handles URLs without protocols, CONNECT requests (domain:port format), and plain domain names.
(urlStr string)
| 60 | // This handles URLs without protocols, CONNECT requests (domain:port format), |
| 61 | // and plain domain names. |
| 62 | func 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 | } |
no outgoing calls
no test coverage detected