python-validators/validators

an ampersand before the first parameter in a url marks it as invalid

Closed this issue · 1 comments

>>> validators.url("http://www.example.com?a=b")
True
>>> validators.url("http://www.example.com?&a=b")
ValidationError(func=url, args={'reason': "bad query field: ''", 'value': 'http://www.example.com?&a=b'})
>>> validators.url("http://www.example.com?a=b&")
ValidationError(func=url, args={'reason': "bad query field: ''", 'value': 'http://www.example.com?a=b&'})

in validators 0.20.0 those urls are valid, but in 0.34.0 the extra '&' makes the validation fail even though browsers seem to be ok with those

Use url("http://www.example.com?a=b&", strict_query=False) See: https://yozachar.github.io/pyvalidators/stable/api/url/