Documentation
¶
Overview ¶
Package hostname splits host:port values and converts IDN host names.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SplitPort ¶
SplitPort splits "host[:port]" into host and port without trimming. A bracketed IPv6 literal keeps its brackets and ends at the first ']', and anything after it but a ":port" is dropped. A value with several colons is returned whole as a bare IPv6 literal. An unclosed '[' is not a literal, so "[a:80" splits like any other host into "[a" and "80".
func ToASCII ¶
ToASCII converts a non-ASCII host to Punycode. IDNA has no concept of a port, so a caller holding "host:port" splits it first: a host with a colon is returned unchanged. So are an ASCII host and one idna.Lookup rejects, so an invalid host fails by not matching.
func ToUnicode ¶
ToUnicode decodes the Punycode labels of host. "xn--" anywhere in host sends all of it through idna.Lookup, which also maps the other labels (width, dots, soft hyphens), and a single label it rejects leaves the whole host unchanged. The xn-- check is case-sensitive, so callers fold ASCII case first.
Types ¶
This section is empty.