Accept authority or URI and extract only the authority and path.
(self, uri, default_port=True)
| 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 |
no test coverage detected