From a8fae65d63099ab0559c3628a633edb2006b7466 Mon Sep 17 00:00:00 2001 From: epi Date: Tue, 10 May 2022 06:44:21 -0500 Subject: [PATCH] allow extensions with prepended . --- src/config/container.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/config/container.rs b/src/config/container.rs index 9161e77..fc6e63d 100644 --- a/src/config/container.rs +++ b/src/config/container.rs @@ -592,7 +592,9 @@ impl Configuration { } if let Some(arg) = args.values_of("extensions") { - config.extensions = arg.map(|val| val.to_string()).collect(); + config.extensions = arg + .map(|val| val.trim_start_matches('.').to_string()) + .collect(); } if let Some(arg) = args.values_of("dont_collect") { @@ -1028,7 +1030,17 @@ impl Configuration { /// uses serde to deserialize the toml into a `Configuration` struct pub(super) fn parse_config(config_file: PathBuf) -> Result { let content = read_to_string(config_file)?; - let config: Self = toml::from_str(content.as_str())?; + let mut config: Self = toml::from_str(content.as_str())?; + + if !config.extensions.is_empty() { + // remove leading periods, if any are found + config.extensions = config + .extensions + .iter() + .map(|ext| ext.trim_start_matches('.').to_string()) + .collect(); + } + Ok(config) } }