1use lazy_static::lazy_static;
3use std::collections::HashSet;
4
5pub struct Validate {}
8
9impl Validate {
10 pub async fn check_str(input: &str) -> bool {
11 if VALID_EXT.contains(input) {
12 return true;
13 }
14
15 false
16 }
17}
18
19lazy_static! {
20 pub static ref VALID_EXT: HashSet<&'static str> = HashSet::from_iter([
21 "7z", "a", "apk", "ar", "bz2", "cab", "cpio", "deb", "dmg", "egg", "gz", "iso", "jar",
23 "lha", "mar", "pea", "rar", "rpm", "s7z", "shar", "tar", "tbz2", "tgz", "tlz", "war",
24 "whl", "xpi", "zip", "zipx", "xz", "pak",
25 "aac", "aiff", "ape", "au", "flac", "gsm", "it", "m3u", "m4a", "mid", "mod", "mp3", "mpa",
27 "pls", "ra", "s3m", "sid", "wav", "wma", "xm",
28 "mobi", "epub", "azw1", "azw3", "azw4", "azw6", "azw", "cbr", "cbz",
30 "exe", "msi", "bin", "command", "sh", "bat", "crx", "bash", "csh", "fish", "ksh", "zsh",
32 "3dm", "3ds", "max", "bmp", "dds", "gif", "jpg", "jpeg", "png", "psd", "xcf", "tga",
34 "thm", "tif", "tiff", "yuv", "ai", "eps", "ps","svg", "dwg", "dxf","gpx", "kml",
35 "kmz", "webp",
36 "1.ada", "2.ada", "ada", "adb", "ads", "asm", "bas", "bash", "bat", "c", "c++", "cbl", "cc",
38 "class", "clj", "cob", "cpp", "cs", "csh", "cxx", "d", "diff", "e", "el", "f", "f77", "f90",
39 "fish", "for", "fth", "ftn", "go", "groovy", "h", "hh", "hpp", "hs", "html", "htm", "hxx",
40 "java", "js", "jsx", "jsp", "ksh", "kt", "lhs", "lisp", "lua", "m", "m4", "nim", "patch", "php",
41 "pl", "po", "pp", "py", "r", "rb", "rs", "s", "scala", "sh", "swg", "swift", "v", "vb", "vcxproj",
42 "xcodeproj","xml", "zsh",
43 "doc", "docx", "ebook", "log", "md", "msg", "odt", "org", "pages", "pdf", "rtf", "rst", "tex", "txt",
45 "wpd", "wps",
46 "3g2", "3gp", "aaf", "asf", "avchd", "avi", "drc", "flv", "m2v", "m4p", "m4v", "mkv", "mng", "mov", "mp2",
48 "mp4", "mpe", "mpeg", "mpg", "mpv", "mxf", "nsv", "ogg", "ogv", "ogm", "qt", "rm", "rmvb", "roq", "srt",
49 "svi", "vob", "webm", "wmv", "yuv",
50 "html", "htm", "css", "js", "jsx", "less", "scss", "wasm", "php"
52 ]);
53}
54
55#[cfg(test)]
56mod tests {
57 use super::*;
58
59 #[tokio::test]
60 async fn test_validate_check() {
61 assert_eq!(true, Validate::check_str("jpg").await);
62 assert_eq!(true, Validate::check_str("m2v").await);
63 assert_eq!(true, Validate::check_str("c++").await);
64 assert_eq!(false, Validate::check_str("").await);
65 }
66}