File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -48,4 +48,5 @@ def __init__(
4848 self .transport = transport (config .api_key , headers = config .headers )
4949
5050 def _build_url (self , path : str ) -> str :
51- return f"{ self .config .base_url } /api{ path } "
51+ normalized_path = path if path .startswith ("/" ) else f"/{ path } "
52+ return f"{ self .config .base_url } /api{ normalized_path } "
Original file line number Diff line number Diff line change 1+ from hyperbrowser import Hyperbrowser
2+ from hyperbrowser .config import ClientConfig
3+
4+
5+ def test_client_build_url_normalizes_leading_slash ():
6+ client = Hyperbrowser (config = ClientConfig (api_key = "test-key" ))
7+ try :
8+ assert client ._build_url ("/session" ) == "https://api.hyperbrowser.ai/api/session"
9+ assert client ._build_url ("session" ) == "https://api.hyperbrowser.ai/api/session"
10+ finally :
11+ client .close ()
12+
13+
14+ def test_client_build_url_uses_normalized_base_url ():
15+ client = Hyperbrowser (
16+ config = ClientConfig (api_key = "test-key" , base_url = "https://example.local/" )
17+ )
18+ try :
19+ assert client ._build_url ("/session" ) == "https://example.local/api/session"
20+ finally :
21+ client .close ()
You can’t perform that action at this time.
0 commit comments