From 1dd796983c0229c6712431af3b7736b6449d8a20 Mon Sep 17 00:00:00 2001 From: gabrik Date: Thu, 7 Dec 2023 16:27:51 +0100 Subject: [PATCH] fix(23): properly parsing regex as Option Signed-off-by: gabrik --- zenoh-plugin-mqtt/src/config.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/zenoh-plugin-mqtt/src/config.rs b/zenoh-plugin-mqtt/src/config.rs index b074c0b..7ade71a 100644 --- a/zenoh-plugin-mqtt/src/config.rs +++ b/zenoh-plugin-mqtt/src/config.rs @@ -129,10 +129,15 @@ fn deserialize_regex<'de, D>(deserializer: D) -> Result, D::Error> where D: Deserializer<'de>, { - let s: String = Deserialize::deserialize(deserializer)?; - Regex::new(&s) - .map(Some) - .map_err(|e| de::Error::custom(format!("Invalid regex 'allow={s}': {e}"))) + let s: Option = Deserialize::deserialize(deserializer)?; + + match s { + Some(s) => Regex::new(&s) + .map(Some) + .map_err(|e| de::Error::custom(format!("Invalid regex 'allow={s}': {e}"))), + + None => Ok(None), + } } fn serialize_allow(v: &Option, serializer: S) -> Result