diff --git a/quetz/database.py b/quetz/database.py index 1720728a..71492735 100644 --- a/quetz/database.py +++ b/quetz/database.py @@ -104,7 +104,8 @@ def sanitize_db_url(db_url: str) -> str: # Attempt 1: Actual parsing, this is ideal but may fail try: parsed_url = make_url(db_url) - return db_url.replace(parsed_url.password, "***") + if parsed_url.password: + return db_url.replace(parsed_url.password, "***") except ArgumentError: pass diff --git a/quetz/tests/test_database.py b/quetz/tests/test_database.py index f66b6daa..3c7be928 100644 --- a/quetz/tests/test_database.py +++ b/quetz/tests/test_database.py @@ -15,6 +15,7 @@ "postgresql+psycopg2://postgres_user:***@localhost:5432/postgres", ), ("A:B@C:1111/DB", "A:***@C:1111/DB"), + ("THISISNOTAURL", "THISISNOTAURL"), ), ) def test_sanitize_db_url(input_url, expected_output_url):