Bugfix(uri test): Fixed is_uri to correctly reject strings without a URI scheme.

This commit is contained in:
Akshat Sinha 2025-12-14 22:35:02 +05:30
parent 9f42cefca6
commit 47bc663840

View file

@ -9,7 +9,8 @@ def is_uri(value, schemes=None):
""" Will verify that the string passed is a valid 'URI', if given a list of valid schemes it will match those """
try:
x = urlparse(value)
isit = all([x.scheme is not None, x.path is not None, not schemes or x.scheme in schemes])
# urlparse returns empty string for scheme when not present, not None
isit = all([x.scheme, x.path is not None, not schemes or x.scheme in schemes])
except Exception as e:
isit = False
return isit