MCPcopy
hub / github.com/scrapy/scrapy / add_http_if_no_scheme

Function add_http_if_no_scheme

scrapy/utils/url.py:47–55  ·  view source on GitHub ↗

Add http as the default scheme if it is missing from the url.

(url: str)

Source from the content-addressed store, hash-verified

45
46
47def 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
58def _is_posix_path(string: str) -> bool:

Callers 4

_extract_proxyMethod · 0.90
_get_agentMethod · 0.90
guess_schemeFunction · 0.85

Calls

no outgoing calls

Tested by 1