MCPcopy Index your code
hub / github.com/RustPython/RustPython / reduce_uri

Method reduce_uri

Lib/urllib/request.py:829–850  ·  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

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