Function
join_link
(link, path=None, query_params=None)
Source from the content-addressed store, hash-verified
| 294 | |
| 295 | |
| 296 | def join_link(link, path=None, query_params=None): |
| 297 | from urllib.parse import urlencode |
| 298 | |
| 299 | if path: |
| 300 | prepend = link.rstrip("/") |
| 301 | href = path.lstrip("/") |
| 302 | |
| 303 | link = f"{prepend}/{href}" |
| 304 | else: |
| 305 | link = link |
| 306 | |
| 307 | if query_params: |
| 308 | query_params = urlencode(query_params) |
| 309 | link = f"{link}?{query_params}" |
| 310 | return link |
| 311 | |
| 312 | |
| 313 | def join_dicts(*dicts): |
Tested by
no test coverage detected