Fixes detection of URLs when there is a subdomain
Adds test