Skip to content

Commit 1296f53

Browse files
committed
Handle non_http_scheme arg
1 parent c192637 commit 1296f53

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

domain_utils/domain_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def hostname_subparts(url, include_ps=False, **kwargs):
116116
return subparts
117117

118118

119-
def get_stripped_url(url, scheme=False):
119+
def get_stripped_url(url, scheme=False, non_http_scheme=None):
120120
"""
121121
Returns a url stripped to (scheme)?+hostname+path
122122
@@ -126,10 +126,14 @@ def get_stripped_url(url, scheme=False):
126126
:type url: str
127127
:param scheme: If True, scheme will be prepended in returned result, defaults to False
128128
:type scheme: bool, optional
129+
:param non_http_scheme: Action to take if scheme is not http or https e.g. file: or 'about:blank'. If None, return empty string. If 'self', return the original URL. Default is None.
130+
:type non_http_scheme: None or str, optional
129131
130132
:return: Returns a url stripped to (scheme)?+hostname+path. Returns empty string if appropriate.
131133
:rtype: str
132134
"""
135+
if non_http_scheme not in [None, 'self']:
136+
raise ValueError('non_http_scheme must be either `None` or `self`')
133137
purl = urlparse(url)
134138
scheme_out = ''
135139
if scheme:

0 commit comments

Comments
 (0)