summaryrefslogtreecommitdiff
path: root/crates/utils/string_proc/src/simple_processer.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2025-09-26 14:18:53 +0800
committer魏曹先生 <1992414357@qq.com>2025-09-26 14:18:53 +0800
commit81c9f47f5d9517ab273a34aeea4b6e40f45aac36 (patch)
tree90e1d033b28fb09d2b9c76b4658b7559acf35c2d /crates/utils/string_proc/src/simple_processer.rs
parentf5e2a00d6701729eb33da5962069c4432db426c8 (diff)
refactor: Update sheet input handling and fix tests
- Modify Sheet::add_input to accept InputPackage instead of separate parameters - Use output_mappings method to generate InputPackage in tests - Update test assertions to match new path transformation logic - Fix mapping count assertions after adding multiple mappings - Clean up string_proc module structure
Diffstat (limited to 'crates/utils/string_proc/src/simple_processer.rs')
-rw-r--r--crates/utils/string_proc/src/simple_processer.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/crates/utils/string_proc/src/simple_processer.rs b/crates/utils/string_proc/src/simple_processer.rs
new file mode 100644
index 0000000..2de5dfc
--- /dev/null
+++ b/crates/utils/string_proc/src/simple_processer.rs
@@ -0,0 +1,15 @@
+/// Sanitizes a file path by replacing special characters with underscores.
+///
+/// This function takes a file path as input and returns a sanitized version
+/// where characters that are not allowed in file paths (such as path separators
+/// and other reserved characters) are replaced with underscores.
+pub fn sanitize_file_path<P: AsRef<str>>(path: P) -> String {
+ let path_str = path.as_ref();
+ path_str
+ .chars()
+ .map(|c| match c {
+ '/' | '\\' | ':' | '*' | '?' | '"' | '<' | '>' | '|' => '_',
+ _ => c,
+ })
+ .collect()
+}