Hostname should support Internationalized domain name (IDN) TLDs
candita opened this issue · comments
Hostname RegEx should support a TLD that exists in the IANA list of TLDs at http://data.iana.org/TLD/tlds-alpha-by-domain.txt,
e.g. XN--11B4C3D, or कॉम.
Currently it disallows numbers and hyphen in the last label of the Hostname (TLD):
^([a-zA-Z0-9\p{S}\p{L}]((-?[a-zA-Z0-9\p{S}\p{L}]{0,62})?)|([a-zA-Z0-9\p{S}\p{L}](([a-zA-Z0-9-\p{S}\p{L}]{0,61}[a-zA-Z0-9\p{S}\p{L}])?)(\.)){1,}([a-zA-Z\p{L}]){2,63})$
Can I change it to allow digits and hyphens in the TLD, or create a new format called HostnameIDN?
^([a-zA-Z0-9\p{S}\p{L}]((-?[a-zA-Z0-9\p{S}\p{L}]{0,62})?)|([a-zA-Z0-9\p{S}\p{L}](([a-zA-Z0-9-\p{S}\p{L}]{0,61}[a-zA-Z0-9\p{S}\p{L}])?)(\.)){1,}([a-zA-Z0-9-\p{L}]){2,63})$
Yeah, but maybe we should just go with https://pkg.go.dev/golang.org/x/net/idna ?
You would make the Hostname RegEx obsolete?
Yeah, we did the same for email addresses because regex'es are always a bit wonky for these things.
https://github.com/go-openapi/strfmt/blob/master/default.go#L122-L126