Improved the URL validator

This commit is contained in:
xemeds
2020-07-23 16:57:16 +00:00
parent 067c62d01b
commit 23d49a47d2
2 changed files with 5 additions and 0 deletions
BIN
View File
Binary file not shown.
+5
View File
@@ -19,6 +19,11 @@ def validate_URL(form, field):
# Raise a ValidationError
raise ValidationError("Invalid URL")
# If the url starts with a slash after http:// or after https:// or just starts with a slash
if field.data.startswith("http:///") or field.data.startswith("https:///") or field.data.startswith("/"):
# Raise a ValidationError
raise ValidationError("Invalid URL")
# If the url ends with a dot and it is the only dot
if field.data.endswith(".") and field.data.count(".") == 1:
# Raise a ValidationError