File tree Expand file tree Collapse file tree 3 files changed +12
-0
lines changed
Expand file tree Collapse file tree 3 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,10 @@ def normalize_base_url(base_url: str) -> str:
6161 raise HyperbrowserError (
6262 "base_url must start with 'https://' or 'http://' and include a host"
6363 )
64+ if parsed_base_url .hostname is None :
65+ raise HyperbrowserError (
66+ "base_url must start with 'https://' or 'http://' and include a host"
67+ )
6468 if parsed_base_url .query or parsed_base_url .fragment :
6569 raise HyperbrowserError (
6670 "base_url must not include query parameters or fragments"
Original file line number Diff line number Diff line change @@ -210,6 +210,8 @@ def test_client_config_rejects_empty_or_invalid_base_url():
210210
211211 with pytest .raises (HyperbrowserError , match = "include a host" ):
212212 ClientConfig (api_key = "test-key" , base_url = "http://" )
213+ with pytest .raises (HyperbrowserError , match = "include a host" ):
214+ ClientConfig (api_key = "test-key" , base_url = "https://:443" )
213215 with pytest .raises (
214216 HyperbrowserError , match = "base_url must contain a valid port number"
215217 ):
@@ -373,6 +375,8 @@ def test_client_config_normalize_base_url_validates_and_normalizes():
373375
374376 with pytest .raises (HyperbrowserError , match = "base_url must start with" ):
375377 ClientConfig .normalize_base_url ("example.local" )
378+ with pytest .raises (HyperbrowserError , match = "include a host" ):
379+ ClientConfig .normalize_base_url ("https://:443" )
376380 with pytest .raises (
377381 HyperbrowserError , match = "base_url must contain a valid port number"
378382 ):
Original file line number Diff line number Diff line change @@ -103,6 +103,10 @@ def test_client_build_url_rejects_runtime_invalid_base_url_changes():
103103 with pytest .raises (HyperbrowserError , match = "include a host" ):
104104 client ._build_url ("/session" )
105105
106+ client .config .base_url = "https://:443"
107+ with pytest .raises (HyperbrowserError , match = "include a host" ):
108+ client ._build_url ("/session" )
109+
106110 client .config .base_url = "https://example.local?foo=bar"
107111 with pytest .raises (
108112 HyperbrowserError , match = "must not include query parameters"
You can’t perform that action at this time.
0 commit comments