refactor(storage): route project DSNs and remove legacy backends
This commit is contained in:
@@ -20,14 +20,17 @@ def _normalize_postgres_dsn(dsn: str) -> str:
|
||||
scheme, rest = dsn.split("://", 1)
|
||||
if scheme not in ("postgresql", "postgres", "postgresql+psycopg"):
|
||||
return dsn
|
||||
if scheme == "postgresql+psycopg":
|
||||
scheme = "postgresql"
|
||||
normalized_dsn = f"{scheme}://{rest}"
|
||||
if "@" not in rest:
|
||||
return dsn
|
||||
return normalized_dsn
|
||||
userinfo, hostinfo = rest.rsplit("@", 1)
|
||||
if ":" not in userinfo:
|
||||
return dsn
|
||||
return normalized_dsn
|
||||
username, password = userinfo.split(":", 1)
|
||||
if "@" not in password:
|
||||
return dsn
|
||||
return normalized_dsn
|
||||
password = password.replace("@", "%40")
|
||||
return f"{scheme}://{username}:{password}@{hostinfo}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user