Conversation
The previous regex was not very good and meant that hostnames containing digits and full stops were not accepted. This one should be more accurate. You can test it [here](https://regex101.com/r/ZVItcq/1). Because regex's are completely unreadable here's how it breaks down: ``` ^ - Start ( - Hostname group [a-zA-Z0-9-]+ - First domain component (?: - Optional subsequent components \.[a-zA-Z0-9-]+ - Each subsequent component is a . followed by the component )* - Any number of subsequent components : - Port separator )? - Hostname group is optional ([0-9]+) - Port, which is mandator $ - End ```
There was a problem hiding this comment.
My understanding is that hostname's can't containe .: https://www.man7.org/linux/man-pages/man7/hostname.7.html#:~:text=Valid%20characters%20for%20hostnames%20are%20ASCII%20%287%29%20letters,translate%20the%20name%20to%20an%20address%20for%20use.
Is this incorrect?
|
Yeah:
Note that specification has other limits like the length of a subdomain and the overall length which I didn't validate, because I think this is basically a sanity check and it seemed like overkill. (And if you want to go for reliable validation regexes are the wrong tool for the job.) |
The previous regex was not very good and meant that hostnames containing digits and full stops were not accepted. This one should be more accurate. You can test it here.
Because regex's are completely unreadable here's how it breaks down:
This PR fixes #