File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,10 @@ def _build_url(self, path: str) -> str:
7373 if not isinstance (path , str ):
7474 raise HyperbrowserError ("path must be a string" )
7575 stripped_path = path .strip ()
76+ if stripped_path != path :
77+ raise HyperbrowserError (
78+ "path must not contain leading or trailing whitespace"
79+ )
7680 if not stripped_path :
7781 raise HyperbrowserError ("path must not be empty" )
7882 if "\\ " in stripped_path :
Original file line number Diff line number Diff line change @@ -42,7 +42,11 @@ def test_client_build_url_uses_normalized_base_url():
4242 )
4343 try :
4444 assert client ._build_url ("/session" ) == "https://example.local/api/session"
45- assert client ._build_url (" session " ) == "https://example.local/api/session"
45+ with pytest .raises (
46+ HyperbrowserError ,
47+ match = "path must not contain leading or trailing whitespace" ,
48+ ):
49+ client ._build_url (" session " )
4650 finally :
4751 client .close ()
4852
@@ -219,7 +223,12 @@ def test_client_build_url_rejects_empty_or_non_string_paths():
219223 client = Hyperbrowser (config = ClientConfig (api_key = "test-key" ))
220224 try :
221225 with pytest .raises (HyperbrowserError , match = "path must not be empty" ):
222- client ._build_url (" " )
226+ client ._build_url ("" )
227+ with pytest .raises (
228+ HyperbrowserError ,
229+ match = "path must not contain leading or trailing whitespace" ,
230+ ):
231+ client ._build_url (" /session" )
223232 with pytest .raises (HyperbrowserError , match = "path must be a string" ):
224233 client ._build_url (123 ) # type: ignore[arg-type]
225234 with pytest .raises (
You can’t perform that action at this time.
0 commit comments