Made the url validator not accept urls from the website
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, SubmitField, ValidationError
|
||||
from wtforms.validators import DataRequired, Length
|
||||
from tiny0.config import WEBSITE_DOMAIN
|
||||
|
||||
# Validates a URL
|
||||
def validate_URL(form, field):
|
||||
@@ -23,6 +24,11 @@ def validate_URL(form, field):
|
||||
# Raise a ValidationError
|
||||
raise ValidationError("Invalid URL")
|
||||
|
||||
# If the url contains the websites domain
|
||||
if WEBSITE_DOMAIN in field.data:
|
||||
# Raise a ValidationError
|
||||
raise ValidationError("Invalid URL")
|
||||
|
||||
# If the URL does not start with http:// and https://
|
||||
if not(field.data.startswith("http://")) and not(field.data.startswith("https://")):
|
||||
# Add https:// to the beginning of the URL
|
||||
|
||||
Reference in New Issue
Block a user