Raise `InvalidURL` for a URL with a scheme but no host

KL
17d ago
+10-2

Closes #616.

Summary

A URL like https:/google.com has a scheme but no host, so _merge_url treated it as relative. Without a base_url it raised a confusing UnsupportedProtocol. With one, it was silently appended to the base:

client = httpx2.Client(base_url="https://www.example.com/")
client.build_request("GET", "https:/google.com").url
# URL("https://www.example.com/google.com")

Both cases now raise InvalidURL, matching requests.

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

AI Disclaimer

This PR was developed with the assistance of either Claude or Codex. I've reviewed and verified the changes.