build_dsn: add assertion

like the systemcheck from 0c14962d92, but dynamically for those
environments (non-docker) in which the system-check might be skipped
This commit is contained in:
Klaas van Schelven
2025-05-12 10:43:53 +02:00
parent 265a3e56ee
commit ab3e6da582

View File

@@ -7,6 +7,10 @@ def _colon_port(port):
def build_dsn(base_url, project_id, public_key):
parts = urllib.parse.urlsplit(base_url)
assert parts.scheme in ("http", "https"), "The BASE_URL setting must be a valid URL (starting with http or https)."
assert parts.hostname, "The BASE_URL setting must be a valid URL. The hostname must be set."
return (f"{ parts.scheme }://{ public_key }@{ parts.hostname }{ _colon_port(parts.port) }" +
f"{ parts.path }/{ project_id }")