MCPcopy Create free account
hub / github.com/authlib/authlib / is_valid_url

Function is_valid_url

authlib/common/urls.py:142–155  ·  view source on GitHub ↗
(url: str, fragments_allowed=True)

Source from the content-addressed store, hash-verified

140
141
142def is_valid_url(url: str, fragments_allowed=True):
143 try:
144 parsed = urlparse.urlparse(url)
145 except ValueError:
146 return False
147
148 # The userinfo component can disguise the actual host,
149 # as in "https://provider.test@attacker.test/".
150 if "@" in parsed.netloc:
151 return False
152
153 return bool(
154 parsed.scheme and parsed.hostname and (fragments_allowed or not parsed.fragment)
155 )

Callers 12

_validate_uriMethod · 0.90
validate_op_tos_uriMethod · 0.90
_validate_uriMethod · 0.90
test_valid_urlFunction · 0.90
test_invalid_urlFunction · 0.90

Calls

no outgoing calls

Tested by 5

test_valid_urlFunction · 0.72
test_invalid_urlFunction · 0.72