File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ def __post_init__(self) -> None:
3636 raise HyperbrowserError (
3737 "base_url must start with 'https://' or 'http://' and include a host"
3838 )
39+ if parsed_base_url .query or parsed_base_url .fragment :
40+ raise HyperbrowserError (
41+ "base_url must not include query parameters or fragments"
42+ )
3943 self .headers = normalize_headers (
4044 self .headers ,
4145 mapping_error_message = "headers must be a mapping of string pairs" ,
Original file line number Diff line number Diff line change @@ -125,6 +125,14 @@ def test_client_config_from_env_rejects_base_url_without_host(monkeypatch):
125125 ClientConfig .from_env ()
126126
127127
128+ def test_client_config_from_env_rejects_base_url_query_or_fragment (monkeypatch ):
129+ monkeypatch .setenv ("HYPERBROWSER_API_KEY" , "test-key" )
130+ monkeypatch .setenv ("HYPERBROWSER_BASE_URL" , "https://example.local?x=1" )
131+
132+ with pytest .raises (HyperbrowserError , match = "must not include query parameters" ):
133+ ClientConfig .from_env ()
134+
135+
128136def test_client_config_normalizes_whitespace_and_trailing_slash ():
129137 config = ClientConfig (api_key = " test-key " , base_url = " https://example.local/ " )
130138
@@ -156,6 +164,9 @@ def test_client_config_rejects_empty_or_invalid_base_url():
156164 with pytest .raises (HyperbrowserError , match = "include a host" ):
157165 ClientConfig (api_key = "test-key" , base_url = "http://" )
158166
167+ with pytest .raises (HyperbrowserError , match = "must not include query parameters" ):
168+ ClientConfig (api_key = "test-key" , base_url = "https://example.local#frag" )
169+
159170
160171def test_client_config_normalizes_headers_to_internal_copy ():
161172 headers = {"X-Correlation-Id" : "abc123" }
You can’t perform that action at this time.
0 commit comments