Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

test: add tests for omniget prefix in sanitized path components

Tonho7bb2e9a2c79b
diff --git a/src-tauri/src/core/filename.rs b/src-tauri/src/core/filename.rs
index 2aa08cab..081b92d0 100644
--- a/src-tauri/src/core/filename.rs
+++ b/src-tauri/src/core/filename.rs
@@ -82,4 +82,28 @@ mod tests {
assert!(!result.contains(c), "char '{}' should be replaced", c);
}
}
+
+ #[test]
+ fn omniget_prefix_basic() {
+ let name = "omniget-My Video Title [abc123]";
+ let result = sanitize_path_component(name);
+ assert!(result.starts_with("omniget-"));
+ assert!(!result.contains(':'));
+ }
+
+ #[test]
+ fn omniget_prefix_with_special_chars() {
+ let name = "omniget-Video: \"Best\" <2024> [id]";
+ let result = sanitize_path_component(name);
+ assert!(result.starts_with("omniget-"));
+ }
+
+ #[test]
+ fn omniget_prefix_long_name() {
+ let long_title = "a".repeat(250);
+ let name = format!("omniget-{} [id]", long_title);
+ let result = sanitize_path_component(&name);
+ assert!(result.starts_with("omniget-"));
+ assert!(result.ends_with("[id]"));
+ }
}