From e1279517a971e2219ae97d920e8ee61da34ff321 Mon Sep 17 00:00:00 2001 From: Vladimir Rubin Date: Mon, 30 Dec 2024 19:01:56 +0200 Subject: [PATCH] feat: handle comments on end of line --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 52da4d7..64cb64c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -48,8 +48,8 @@ impl Config { .filter(|l| !l.is_empty()) .filter(|l| !l.starts_with('#')) { - if line.starts_with('[') && line.ends_with(']') { - current_section = line[1..line.len() - 1].to_string(); + if line.starts_with('[') && line.contains(']') { + current_section = line[1..line.find(']').unwrap()].to_string(); } else if let Some((key, value)) = line.split_once('=') { let key_trimmed_string = key.trim().replace('"', ""); let key_trimmed = key_trimmed_string.as_str();