MCPcopy
hub / github.com/caddyserver/certmagic / hostOnly

Function hostOnly

certificates.go:651–662  ·  view source on GitHub ↗

hostOnly returns only the host portion of hostport. If there is no port or if there is an error splitting the port off, the whole input string is returned.

(hostport string)

Source from the content-addressed store, hash-verified

649// If there is no port or if there is an error splitting
650// the port off, the whole input string is returned.
651func hostOnly(hostport string) string {
652 host, _, err := net.SplitHostPort(hostport)
653 if err != nil {
654 // May be a bare IPv6 address in brackets without a port (e.g. "[::1]").
655 // net.SplitHostPort requires a port when brackets are present, so strip them.
656 if len(hostport) > 1 && hostport[0] == '[' && hostport[len(hostport)-1] == ']' {
657 return hostport[1 : len(hostport)-1]
658 }
659 return hostport // OK; probably had no port to begin with
660 }
661 return host
662}
663
664// MatchWildcard returns true if subject (a candidate DNS name)
665// matches wildcard (a reference DNS name), mostly according to

Callers 10

httpRedirectHandlerFunction · 0.85
GetACMEChallengeFunction · 0.85
TestHostOnlyFunction · 0.85
solveHTTPChallengeFunction · 0.85
SubjectIsInternalFunction · 0.85
isInternalIPFunction · 0.85
MatchWildcardFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestHostOnlyFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…