1
0
Fork 0
mirror of https://github.com/SinTan1729/chhoto-url synced 2025-02-05 13:52:33 -06:00

fix: Disregard empty Site URL

This commit is contained in:
Sayantan Santra 2025-01-06 11:11:09 +05:30
parent 5183279cab
commit eb4f05a87b
Signed by: SinTan1729
GPG key ID: 0538DD402EA50898
2 changed files with 8 additions and 6 deletions

View file

@ -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 || {

View file

@ -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 {