Add http as the default scheme if it is missing from the url.
(url: str)
| 45 | |
| 46 | |
| 47 | def add_http_if_no_scheme(url: str) -> str: |
| 48 | """Add http as the default scheme if it is missing from the url.""" |
| 49 | match = re.match(r"^\w+://", url, flags=re.IGNORECASE) |
| 50 | if not match: |
| 51 | parts = urlparse(url) |
| 52 | scheme = "http:" if parts.netloc else "http://" |
| 53 | url = scheme + url |
| 54 | |
| 55 | return url |
| 56 | |
| 57 | |
| 58 | def _is_posix_path(string: str) -> bool: |
no outgoing calls