From eb4f05a87b3968fb335ae7a3f3db8a6dca4152ad Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Mon, 6 Jan 2025 11:11:09 +0530 Subject: [PATCH] fix: Disregard empty Site URL --- actix/src/main.rs | 9 ++++----- actix/src/services.rs | 5 ++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/actix/src/main.rs b/actix/src/main.rs index da27c68..5d41a4e 100644 --- a/actix/src/main.rs +++ b/actix/src/main.rs @@ -47,11 +47,10 @@ async fn main() -> Result<()> { } // Tell the user that the server has started, and where it is listening to, rather than simply outputting nothing - eprintln!( - "Server has started at 0.0.0.0 on port {}. Configured Site URL is: {}", - port, - env::var("site_url").unwrap_or(String::from("http://localhost")) - ); + eprintln!("Server has started at 0.0.0.0 on port {port}."); + if let Some(site_url) = env::var("site_url").ok().filter(|s| !s.trim().is_empty()) { + eprintln!("Configured Site URL is: {site_url}."); + } // Actually start the server HttpServer::new(move || { diff --git a/actix/src/services.rs b/actix/src/services.rs index 4a10d4d..a5c80db 100644 --- a/actix/src/services.rs +++ b/actix/src/services.rs @@ -61,7 +61,10 @@ pub async fn add_link( .expect("Supplied port is not an integer"); let url = format!( "{}:{}", - env::var("site_url").unwrap_or(String::from("http://localhost")), + env::var("site_url") + .ok() + .filter(|s| !s.trim().is_empty()) + .unwrap_or(String::from("http://localhost")), port ); let response = CreatedURL {