bookwyrm/bookwyrm/utils/validate.py

16 lines
336 B
Python
Raw Normal View History

2022-12-30 16:55:47 +00:00
"""Validations"""
2023-07-23 18:50:44 +00:00
from typing import Optional
from bookwyrm.settings import BASE_URL
2022-12-30 16:55:47 +00:00
def validate_url_domain(url: Optional[str]) -> Optional[str]:
2022-12-30 16:55:47 +00:00
"""Basic check that the URL starts with the instance domain name"""
if url is None:
return None
2023-01-01 19:51:23 +00:00
if not url.startswith(BASE_URL):
return None
2022-12-30 16:55:47 +00:00
return url