Skip to content

Commit 0e29b79

Browse files
committed
db: Simplify connect_now() implementation
`connect_now()` appears to share a lot of code with the `connection_url()` function, so it should be safe to use one inside of the other
1 parent e433360 commit 0e29b79

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/db.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,8 @@ impl Deref for DieselPooledConn<'_> {
5656
}
5757

5858
pub fn connect_now() -> ConnectionResult<PgConnection> {
59-
let mut url = Url::parse(&crate::env("DATABASE_URL")).expect("Invalid database URL");
60-
if dotenv::var("HEROKU").is_ok() && !url.query_pairs().any(|(k, _)| k == "sslmode") {
61-
url.query_pairs_mut().append_pair("sslmode", "require");
62-
}
63-
PgConnection::establish(&url.to_string())
59+
let url = connection_url(&crate::env("DATABASE_URL"));
60+
PgConnection::establish(&url)
6461
}
6562

6663
pub fn connection_url(url: &str) -> String {

0 commit comments

Comments
 (0)