From c73d1fff6a7284057f5a87d160f59738fe9f1294 Mon Sep 17 00:00:00 2001 From: Bart Schuurmans Date: Tue, 2 Apr 2024 14:27:47 +0200 Subject: [PATCH] Remove unnecessary exceptions from validate_url_domain --- bookwyrm/tests/test_utils.py | 4 ---- bookwyrm/utils/validate.py | 7 ++----- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/bookwyrm/tests/test_utils.py b/bookwyrm/tests/test_utils.py index 61ed2262c..ed62050a8 100644 --- a/bookwyrm/tests/test_utils.py +++ b/bookwyrm/tests/test_utils.py @@ -25,7 +25,3 @@ class TestUtils(TestCase): self.assertIsNone( validate_url_domain("https://up-to-no-good.tld/bad-actor.exe") ) - - def test_default_url_domain(self): - """Check with a default URL""" - self.assertEqual(validate_url_domain("/"), "/") diff --git a/bookwyrm/utils/validate.py b/bookwyrm/utils/validate.py index ed1b00b0e..459bc70a6 100644 --- a/bookwyrm/utils/validate.py +++ b/bookwyrm/utils/validate.py @@ -4,14 +4,11 @@ from typing import Optional from bookwyrm.settings import DOMAIN, USE_HTTPS -def validate_url_domain(url: str) -> Optional[str]: +def validate_url_domain(url: Optional[str]) -> Optional[str]: """Basic check that the URL starts with the instance domain name""" - if not url: + if url is None: return None - if url == "/": - return url - protocol = "https://" if USE_HTTPS else "http://" origin = f"{protocol}{DOMAIN}"