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)
| 649 | // If there is no port or if there is an error splitting |
| 650 | // the port off, the whole input string is returned. |
| 651 | func 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 |
no outgoing calls
searching dependent graphs…