You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the url validator it converts the string to lower case.
Is there anyway to stop this from happening? Not sure if this is a bug or by design but it causes me some issues as I need the case to be preserved for the bit 'THIS_IS_UPPER' in the following example.
I'm afraid that in v.1.3.4, validators.url() will always return a lowercase URL. While this is currently by design, it's actually a design error, since per the related RFC specs (which I just checked) portions of URLs may be case sensitive (specifically the path portion - domains are case insensitive). The bug will be fixed in v.1.3.5.
In the meantime, an alternative is to use the corresponding checkers.is_url() function. It will not return a URL, but it will give you True if your (case-sensitive) value is a valid URL:
from validator_collection import validators, checkers
value = 'https://www.myDOMAIN.co.uk/THIS_IS_IN_UPPER'
lowercase_value = validators.url(value)
is_valid = checkers.is_url(value)
print(lowercase_value)
# Prints 'https://www.mydomain.co.uk/this_is_in_upper'
print(is_valid)
# Prints 'True'
Hi,
When using the url validator it converts the string to lower case.
Is there anyway to stop this from happening? Not sure if this is a bug or by design but it causes me some issues as I need the case to be preserved for the bit 'THIS_IS_UPPER' in the following example.
value ='https://www.myDOMAIN.co.uk/THIS_IS_IN_UPPER'
url = validators.url(value, allow_empty = False)
print(f'validated url: {url}')
Many thanks
The text was updated successfully, but these errors were encountered: