Merge a URL argument together with any 'base_url' on the client, to create the URL used for the outgoing request.
(self, url: URL | str)
| 389 | ) |
| 390 | |
| 391 | def _merge_url(self, url: URL | str) -> URL: |
| 392 | """ |
| 393 | Merge a URL argument together with any 'base_url' on the client, |
| 394 | to create the URL used for the outgoing request. |
| 395 | """ |
| 396 | merge_url = URL(url) |
| 397 | if merge_url.is_relative_url: |
| 398 | # To merge URLs we always append to the base URL. To get this |
| 399 | # behaviour correct we always ensure the base URL ends in a '/' |
| 400 | # separator, and strip any leading '/' from the merge URL. |
| 401 | # |
| 402 | # So, eg... |
| 403 | # |
| 404 | # >>> client = Client(base_url="https://www.example.com/subpath") |
| 405 | # >>> client.base_url |
| 406 | # URL('https://www.example.com/subpath/') |
| 407 | # >>> client.build_request("GET", "/path").url |
| 408 | # URL('https://www.example.com/subpath/path') |
| 409 | merge_raw_path = self.base_url.raw_path + merge_url.raw_path.lstrip(b"/") |
| 410 | return self.base_url.copy_with(raw_path=merge_raw_path) |
| 411 | return merge_url |
| 412 | |
| 413 | def _merge_cookies(self, cookies: CookieTypes | None = None) -> CookieTypes | None: |
| 414 | """ |
no test coverage detected