From 9671e623706cf8a75d3898fc61822ea3b1be1250 Mon Sep 17 00:00:00 2001 From: YounessBird <67457600+YounessBird@users.noreply.github.com> Date: Tue, 5 Jul 2022 07:46:42 +0100 Subject: [PATCH] change config methods to use lowercase keys --- src/config.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/config.rs b/src/config.rs index 27b318dd..320b72e2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -110,7 +110,8 @@ impl Config { where T: Into, { - self.defaults.insert(key.parse()?, value.into()); + self.defaults + .insert(key.to_lowercase().as_str().parse()?, value.into()); #[allow(deprecated)] self.refresh() @@ -129,7 +130,8 @@ impl Config { where T: Into, { - self.overrides.insert(key.parse()?, value.into()); + self.overrides + .insert(key.to_lowercase().as_str().parse()?, value.into()); #[allow(deprecated)] self.refresh() @@ -137,7 +139,7 @@ impl Config { #[deprecated(since = "0.12.0", note = "please use 'ConfigBuilder' instead")] pub fn set_once(&mut self, key: &str, value: Value) -> Result<()> { - let expr: path::Expression = key.parse()?; + let expr: path::Expression = key.to_lowercase().as_str().parse()?; // Traverse the cache using the path to (possibly) retrieve a value if let Some(ref mut val) = expr.get_mut(&mut self.cache) { @@ -149,6 +151,8 @@ impl Config { } pub fn get<'de, T: Deserialize<'de>>(&self, key: &str) -> Result { + let k = key.to_lowercase(); + let key = k.as_str(); // Parse the key into a path expression let expr: path::Expression = key.parse()?;