MCPcopy Create free account
hub / github.com/TheSmallHanCat/flow2api / _parse_proxy_url

Function _parse_proxy_url

src/services/browser_captcha_personal.py:1002–1015  ·  view source on GitHub ↗

Parse a proxy URL into (protocol, host, port, username, password).

(proxy_url: str)

Source from the content-addressed store, hash-verified

1000
1001
1002def _parse_proxy_url(proxy_url: str):
1003 """Parse a proxy URL into (protocol, host, port, username, password)."""
1004 if not proxy_url:
1005 return None, None, None, None, None
1006 url = proxy_url.strip()
1007 if not re.match(r'^(http|https|socks5h?|socks5)://', url):
1008 url = f"http://{url}"
1009 m = re.match(r'^(socks5h?|socks5|http|https)://(?:([^:]+):([^@]+)@)?([^:]+):(\d+)$', url)
1010 if not m:
1011 return None, None, None, None, None
1012 protocol, username, password, host, port = m.groups()
1013 if protocol == "socks5h":
1014 protocol = "socks5"
1015 return protocol, host, port, username, password
1016
1017
1018def _compose_proxy_url(

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected