From 418d62c33672dd870e1f798241893d5582eb6675 Mon Sep 17 00:00:00 2001 From: xujing Date: Mon, 7 Aug 2023 15:04:43 +0800 Subject: [PATCH] fix(devmaster): last spaces should not be converted to '_' in replace_whitespace --- exts/devmaster/src/lib/utils/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/exts/devmaster/src/lib/utils/mod.rs b/exts/devmaster/src/lib/utils/mod.rs index 987cdfb6..cfd18b5d 100644 --- a/exts/devmaster/src/lib/utils/mod.rs +++ b/exts/devmaster/src/lib/utils/mod.rs @@ -176,6 +176,8 @@ pub(crate) fn replace_ifname(s: &str) -> String { /// It uses a regular expression to match one or more whitespace characters. /// The input string is not modified, and a new string with the replacements is returned. pub(crate) fn replace_whitespace(s: &str) -> String { + // Remove consecutive spaces after the last non-space character + let s = s.trim_end_matches(' '); // Create a regular expression to match one or more whitespace characters. let re = Regex::new(r"\s+").unwrap(); // Use the regular expression to replace all matches with underscores. -- Gitee