From e2a4be45897d2a4016f4bb4c5f4dea0702ce1d2b Mon Sep 17 00:00:00 2001 From: Yuwei Ba Date: Sun, 3 Nov 2024 01:42:55 +1100 Subject: [PATCH] apply yaml merge (#637) --- clash_lib/src/config/def.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/clash_lib/src/config/def.rs b/clash_lib/src/config/def.rs index 948df383b..411d77b78 100644 --- a/clash_lib/src/config/def.rs +++ b/clash_lib/src/config/def.rs @@ -358,7 +358,21 @@ impl FromStr for Config { type Err = Error; fn from_str(s: &str) -> Result { - serde_yaml::from_str(s).map_err(|x| { + let mut val: Value = serde_yaml::from_str(s).map_err(|x| { + Error::InvalidConfig(format!( + "cound not parse config content {}: {}", + s, x + )) + })?; + + val.apply_merge().map_err(|x| { + Error::InvalidConfig(format!( + "failed to process anchors in config content {}: {}", + s, x + )) + })?; + + serde_yaml::from_value(val).map_err(|x| { Error::InvalidConfig(format!( "cound not parse config content {}: {}", s, x