software/rapid-cdn: avoid RegExp to validate hostnames
Problem
Requesting a frontend with domain name rapid.university
or просто.рф
triggers a warning because these domains do not pass the RegExp check ^([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,6}$
.
For the first domain, the behaviour is opposed to RFC1123, which allows TLDs of at least 63 characters, and strongly suggests not to limit anything less than 255 characters (see section 2.1).
For the second domain, called an Internationalized Domain Name, the feature is recent-ish, and was introduced by RFC5890.
Proposed change
Using RegExp to validate hostnames is a bad practice, and has a lot of reasons to be wrong.
On top of that, the JSON Schema specification allows, since draft 7, to validate hostnames against an IDN hostname, by using the idn-hostname
format (see the string format documentation).
I suggest to use this format instead of our current RegExp check, so that we support all TLDs, and now just those with less than 6 characters (why?), and allow IDNs.