Handle URLs where the query part follows the hostname without a slash in between

For example, in http://www.example.com?a=b the hostname is "www.example.com", not "www.example.com?a=b".  See RFC 3986, section 3.