mirror of
https://github.com/r4sas/py-i2phosts
synced 2025-01-09 14:28:03 +00:00
validation.py: strip leading and trailing whitespaces from hostname
This commit is contained in:
parent
6a50774e5f
commit
573efddf8b
@ -11,8 +11,8 @@ def validate_hostname(data):
|
|||||||
Here we do additional hostname validation as described in
|
Here we do additional hostname validation as described in
|
||||||
http://www.i2p2.i2p/naming.html
|
http://www.i2p2.i2p/naming.html
|
||||||
"""
|
"""
|
||||||
# convert hostname to lowercase
|
# convert hostname to lowercase and strip leading and trailing whitespaces
|
||||||
data = data.lower()
|
data = data.lower().strip()
|
||||||
# Must end with '.i2p'.
|
# Must end with '.i2p'.
|
||||||
if re.match(r'.*\.i2p$', data) == None:
|
if re.match(r'.*\.i2p$', data) == None:
|
||||||
raise forms.ValidationError('Hostname doesn\'t ends with .i2p')
|
raise forms.ValidationError('Hostname doesn\'t ends with .i2p')
|
||||||
|
Loading…
Reference in New Issue
Block a user