MCPcopy Index your code
hub / github.com/python/cpython / reduce_uri

Method reduce_uri

Lib/urllib/request.py:831–852  ·  view source on GitHub ↗

Accept authority or URI and extract only the authority and path.

(self, uri, default_port=True)

Source from the content-addressed store, hash-verified

829 return None, None
830
831 def reduce_uri(self, uri, default_port=True):
832 """Accept authority or URI and extract only the authority and path."""
833 # note HTTP URLs do not have a userinfo component
834 parts = urlsplit(uri)
835 if parts[1]:
836 # URI
837 scheme = parts[0]
838 authority = parts[1]
839 path = parts[2] or '/'
840 else:
841 # host or host:port
842 scheme = None
843 authority = uri
844 path = '/'
845 host, port = _splitport(authority)
846 if default_port and port is None and scheme is not None:
847 dport = {"http": 80,
848 "https": 443,
849 }.get(scheme)
850 if dport is not None:
851 authority = "%s:%d" % (host, dport)
852 return authority, path
853
854 def is_suburi(self, base, test):
855 """Check if test is below base in a URI tree

Callers 4

add_passwordMethod · 0.95
find_user_passwordMethod · 0.95
update_authenticatedMethod · 0.80
is_authenticatedMethod · 0.80

Calls 3

urlsplitFunction · 0.90
_splitportFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected