From 8dc050895ae1c9a33f925f3212d5aac6b701024a Mon Sep 17 00:00:00 2001 From: Joe Date: Fri, 6 Feb 2026 22:52:31 -0600 Subject: [PATCH] Enhance experience name sanitization in CloneCommand - Updated the `sanitize_name` function to remove noise words, specifically "testing", from experience names. - Added unit tests to verify the removal of "testing" in various input scenarios, ensuring consistent sanitization of folder names. --- src/cli/clone.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/cli/clone.rs b/src/cli/clone.rs index 1d0bdcf4..f181a790 100644 --- a/src/cli/clone.rs +++ b/src/cli/clone.rs @@ -168,8 +168,9 @@ fn fetch_experience_name(place_id: u64) -> anyhow::Result { /// Sanitize a Roblox experience name into a valid folder name. /// /// 1. Strip `[...]` and `(...)` sections -/// 2. Keep only ASCII alphanumeric and spaces -/// 3. Collapse whitespace, lowercase, join with hyphens +/// 2. Remove noise words (e.g. "testing") +/// 3. Keep only ASCII alphanumeric and spaces +/// 4. Collapse whitespace, lowercase, join with hyphens fn sanitize_name(name: &str) -> String { // Remove [...] and (...) sections (handles nesting) let mut cleaned = String::with_capacity(name.len()); @@ -192,6 +193,7 @@ fn sanitize_name(name: &str) -> String { .split(|c: char| !(c.is_ascii_alphanumeric() || c == ' ')) .collect::() .split_whitespace() + .filter(|w| !w.eq_ignore_ascii_case("testing")) .collect::>() .join("-") .to_lowercase() @@ -231,4 +233,11 @@ mod tests { fn sanitize_only_special_chars() { assert_eq!(sanitize_name("🎮🌊⚡"), ""); } + + #[test] + fn sanitize_removes_testing() { + assert_eq!(sanitize_name("My Game Testing"), "my-game"); + assert_eq!(sanitize_name("TESTING My Game"), "my-game"); + assert_eq!(sanitize_name("My testing Game"), "my-game"); + } }