diff --git a/plugins/deep-link/src/config.rs b/plugins/deep-link/src/config.rs index ca437a5e6..80f0a4c08 100644 --- a/plugins/deep-link/src/config.rs +++ b/plugins/deep-link/src/config.rs @@ -6,15 +6,30 @@ #![allow(dead_code)] -use serde::Deserialize; +use serde::{Deserialize, Deserializer}; #[derive(Deserialize)] pub struct AssociatedDomain { + #[serde(deserialize_with = "deserialize_associated_host")] pub host: String, #[serde(default, alias = "path-prefix", rename = "pathPrefix")] pub path_prefix: Vec, } +fn deserialize_associated_host<'de, D>(deserializer: D) -> Result +where + D: Deserializer<'de>, +{ + let host = String::deserialize(deserializer)?; + if let Some((scheme, _host)) = host.split_once("://") { + Err(serde::de::Error::custom(format!( + "host `{host}` cannot start with a scheme, please remove the `{scheme}://` prefix" + ))) + } else { + Ok(host) + } +} + #[derive(Deserialize)] pub struct Config { pub domains: Vec,