From 7a84cc029016cdc70bf5a107407b9ce57960b8e0 Mon Sep 17 00:00:00 2001 From: Antoine Gersant Date: Wed, 9 Oct 2024 14:53:42 -0700 Subject: [PATCH] Fixed a bug where blank DDNS url turned into '/' --- src/app/config.rs | 6 ++++-- src/server/axum/api.rs | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/app/config.rs b/src/app/config.rs index 37539fd..4112db6 100644 --- a/src/app/config.rs +++ b/src/app/config.rs @@ -254,11 +254,13 @@ mod test { use super::*; #[tokio::test] - async fn blank_config_is_valid() { + async fn blank_config_round_trip() { let config_path = PathBuf::from_iter(["test-data", "blank.toml"]); - Manager::new(&config_path, auth::Secret([0; 32])) + let manager = Manager::new(&config_path, auth::Secret([0; 32])) .await .unwrap(); + let config: storage::Config = manager.config.read().await.clone().into(); + assert_eq!(config, storage::Config::default()); } #[tokio::test] diff --git a/src/server/axum/api.rs b/src/server/axum/api.rs index 6611b92..61236c4 100644 --- a/src/server/axum/api.rs +++ b/src/server/axum/api.rs @@ -111,8 +111,9 @@ async fn get_settings( ddns_update_url: config_manager .get_ddns_update_url() .await - .unwrap_or_default() - .to_string(), + .as_ref() + .map(http::Uri::to_string) + .unwrap_or_default(), }; Ok(Json(settings)) }