File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,6 +38,8 @@ def normalize_base_url(base_url: str) -> str:
3838 raise HyperbrowserError ("base_url must not contain newline characters" )
3939 if any (character .isspace () for character in normalized_base_url ):
4040 raise HyperbrowserError ("base_url must not contain whitespace characters" )
41+ if "\\ " in normalized_base_url :
42+ raise HyperbrowserError ("base_url must not contain backslashes" )
4143
4244 parsed_base_url = urlparse (normalized_base_url )
4345 if (
Original file line number Diff line number Diff line change @@ -218,6 +218,10 @@ def test_client_config_rejects_empty_or_invalid_base_url():
218218 HyperbrowserError , match = "base_url must not contain whitespace characters"
219219 ):
220220 ClientConfig (api_key = "test-key" , base_url = "https://example .local" )
221+ with pytest .raises (
222+ HyperbrowserError , match = "base_url must not contain backslashes"
223+ ):
224+ ClientConfig (api_key = "test-key" , base_url = "https://example.local\\ api" )
221225
222226
223227def test_client_config_normalizes_headers_to_internal_copy ():
@@ -333,3 +337,7 @@ def test_client_config_normalize_base_url_validates_and_normalizes():
333337 HyperbrowserError , match = "base_url must not contain whitespace characters"
334338 ):
335339 ClientConfig .normalize_base_url ("https://example.local/\t api" )
340+ with pytest .raises (
341+ HyperbrowserError , match = "base_url must not contain backslashes"
342+ ):
343+ ClientConfig .normalize_base_url ("https://example.local\\ api" )
Original file line number Diff line number Diff line change @@ -110,6 +110,12 @@ def test_client_build_url_rejects_runtime_invalid_base_url_changes():
110110 ):
111111 client ._build_url ("/session" )
112112
113+ client .config .base_url = "https://example.local\\ api"
114+ with pytest .raises (
115+ HyperbrowserError , match = "base_url must not contain backslashes"
116+ ):
117+ client ._build_url ("/session" )
118+
113119 client .config .base_url = " "
114120 with pytest .raises (HyperbrowserError , match = "base_url must not be empty" ):
115121 client ._build_url ("/session" )
You can’t perform that action at this time.
0 commit comments