diff options
| author | 魏曹先生 <1992414357@qq.com> | 2025-09-26 17:40:39 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-26 17:40:39 +0800 |
| commit | cf85a0a75b6b6b201b4ee0906bb756b19f957af8 (patch) | |
| tree | 78138b8564d132edba20226a7522532746bfb79e /crates/utils/string_proc/src/simple_processer.rs | |
| parent | f5e2a00d6701729eb33da5962069c4432db426c8 (diff) | |
| parent | 4951e2e98bab7a2996893939ee77f0279145b556 (diff) | |
Merge pull request #10 from JustEnoughVCS/jvcs_dev
Jvcs dev
Diffstat (limited to 'crates/utils/string_proc/src/simple_processer.rs')
| -rw-r--r-- | crates/utils/string_proc/src/simple_processer.rs | 15 |
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() +} |
