File tree Expand file tree Collapse file tree 3 files changed +18
-0
lines changed
Expand file tree Collapse file tree 3 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ def normalize_base_url(base_url: str) -> str:
3636 raise HyperbrowserError ("base_url must not be empty" )
3737 if "\n " in normalized_base_url or "\r " in normalized_base_url :
3838 raise HyperbrowserError ("base_url must not contain newline characters" )
39+ if any (character .isspace () for character in normalized_base_url ):
40+ raise HyperbrowserError ("base_url must not contain whitespace characters" )
3941
4042 parsed_base_url = urlparse (normalized_base_url )
4143 if (
Original file line number Diff line number Diff line change @@ -214,6 +214,11 @@ def test_client_config_rejects_empty_or_invalid_base_url():
214214 ):
215215 ClientConfig (api_key = "test-key" , base_url = "https://example.local/\n api" )
216216
217+ with pytest .raises (
218+ HyperbrowserError , match = "base_url must not contain whitespace characters"
219+ ):
220+ ClientConfig (api_key = "test-key" , base_url = "https://example .local" )
221+
217222
218223def test_client_config_normalizes_headers_to_internal_copy ():
219224 headers = {"X-Correlation-Id" : "abc123" }
@@ -323,3 +328,8 @@ def test_client_config_normalize_base_url_validates_and_normalizes():
323328 HyperbrowserError , match = "base_url must not contain newline characters"
324329 ):
325330 ClientConfig .normalize_base_url ("https://example.local/\n api" )
331+
332+ with pytest .raises (
333+ HyperbrowserError , match = "base_url must not contain whitespace characters"
334+ ):
335+ ClientConfig .normalize_base_url ("https://example.local/\t api" )
Original file line number Diff line number Diff line change @@ -104,6 +104,12 @@ def test_client_build_url_rejects_runtime_invalid_base_url_changes():
104104 ):
105105 client ._build_url ("/session" )
106106
107+ client .config .base_url = "https://example .local"
108+ with pytest .raises (
109+ HyperbrowserError , match = "base_url must not contain whitespace characters"
110+ ):
111+ client ._build_url ("/session" )
112+
107113 client .config .base_url = " "
108114 with pytest .raises (HyperbrowserError , match = "base_url must not be empty" ):
109115 client ._build_url ("/session" )
You can’t perform that action at this time.
0 commit comments