Rewrite handling of URLs without a protocol.

The previous code used setHostAndPort which doesn't work with IDN
domains. Fixes #9063.