From 45288392970b53db0f7ba0ddda9b8333aa29ac00 Mon Sep 17 00:00:00 2001 From: dev0 Date: Sun, 3 Nov 2024 01:08:44 +1100 Subject: [PATCH] apply yaml merge --- 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 948df383..411d77b7 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