Derive with improvements instead of straight copy

Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
pull/83085/head
Matt Martz 7 months ago committed by GitHub
parent 2447f66eda
commit c206d4f335
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -303,17 +303,15 @@ class UnixHTTPHandler(urllib.request.HTTPHandler):
class ProxyHandler(urllib.request.ProxyHandler): class ProxyHandler(urllib.request.ProxyHandler):
_SPLITPORT_RE = re.compile('(.*):([0-9]*)', re.DOTALL) _SPLITPORT_RE = re.compile('(.*):([0-9]{1,5})', re.DOTALL)
@classmethod @classmethod
def _splitport(cls, host): def _splitport(cls, host):
# Copied from cpython urllib.parse # Derived from cpython urllib.parse
match = cls._SPLITPORT_RE.fullmatch(host) port = None
if match: if (match := cls._SPLITPORT_RE.fullmatch(host)):
host, port = match.groups() host, port = match.groups()
if port: return host, port or None
return host, port
return host, None
@staticmethod @staticmethod
def _matches(host, port, bypass_network, bypass_port, scheme): def _matches(host, port, bypass_network, bypass_port, scheme):

Loading…
Cancel
Save