Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL validator converting all to lower case #34

Closed
danielwmartin opened this issue May 17, 2019 · 1 comment · Fixed by #35
Closed

URL validator converting all to lower case #34

danielwmartin opened this issue May 17, 2019 · 1 comment · Fixed by #35
Assignees
Labels
bug Something isn't working question Further information is requested
Milestone

Comments

@danielwmartin
Copy link

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}')

validated url:https://www.mydomain.co.uk/this_is_in_upper

Many thanks

@insightindustry insightindustry self-assigned this May 17, 2019
@insightindustry insightindustry added question Further information is requested bug Something isn't working labels May 17, 2019
@insightindustry insightindustry added this to the v.1.3.4 milestone May 17, 2019
@insightindustry
Copy link
Owner

insightindustry commented May 17, 2019

Hi @danielwmartin !

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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants