From f794748df24dba071d8c2e3152c670d9f9f8b4a1 Mon Sep 17 00:00:00 2001 From: Eric Naim Date: Mon, 23 Mar 2026 22:00:33 +0800 Subject: [PATCH] data: Trim newlines from product_name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fs::read_to_string(path) returns `product_name\n`. This breaks pattern matching with string anchors fail as the pattern fails to match against the newline. Trim newlines from product_name so that matching patterns with string anchors work correctly. Fixes: 7c3043696a68 ("👷 support product name pattern match") Signed-off-by: Eric Naim --- src/data.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/data.rs b/src/data.rs index 325affd..15b430f 100644 --- a/src/data.rs +++ b/src/data.rs @@ -242,7 +242,8 @@ pub fn get_all_devices_of_profile(devices: &ListOfDevicesT, profile: &Profile) - if let Some(product_name_re) = &product_name_re { let product_name = fs::read_to_string("/sys/devices/virtual/dmi/id/product_name") .expect("Failed to read product name"); - if !product_name_re.is_match(&product_name) { + let product_name = product_name.trim(); + if !product_name_re.is_match(product_name) { return vec![]; } }