CodeSOD: Not My Domain
by Remy Porter from The Daily WTF on (#6G475)
Dian found this code snippet.
String[] key_value = url.split("\\.");for (int i=key_value.length; i>0; i--) { if (i > 1) domain = key_value[i-2]+"."+key_value[i-1]; break;}
"I'm still not sure what this is supposed to do," Dian writes.
I believe this is someone's attempt to extract the TLD and primary domain from a URL, e.g. www.mysite.com becomes mysite.com. (Remember when wwws were on every domain name?) Why they chose to use a loop that only executes once, I'll never understand.
[Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!