Hmm that’s pretty nasty.. can’t say I am a fan.
Couldn’t we have a simple regex that allows a few 2 and 3 letter dotted phrases at the end?
\w{3,}\.\w{1,3}(\.\w{1,3})$
TLDs are a pain though, if they are long like funky.community… stuff is gonna break. I guess the general logic would be
- grab the rightmost period and word chars next to it
- if it is too short, grab the next leftward period and word too
This would handle com.au as it is clearly way too short to be a real domain. com.com is also too short, I think. so the threshold is “must be more than 7 chars with just one period”