diff --git a/src/defaults.rs b/src/defaults.rs index c82ddcc..fa068dc 100644 --- a/src/defaults.rs +++ b/src/defaults.rs @@ -51,8 +51,11 @@ pub const BINARY_FILE_EXTENSIONS: &[&str] = &[ "wma", "ra", "ram", "ape", "opus", "amr", "awb", // Video + // Note: .ts (MPEG transport stream) extension is intentionally excluded + // to avoid conflicts with TypeScript files, which are more common in code repositories. + // Actual binary .ts files will still be detected via content inspection. "mp4", "m4v", "mov", "avi", "wmv", "mkv", "flv", "f4v", "f4p", "f4a", "f4b", "3gp", - "3g2", "mpeg", "mpg", "mpe", "m1v", "m2v", "ts", "mts", "m2ts", "vob", "rm", "rmvb", + "3g2", "mpeg", "mpg", "mpe", "m1v", "m2v", "mts", "m2ts", "vob", "rm", "rmvb", "asf", "ogv", "ogm", "webm", "dv", "divx", "xvid", // Font Files diff --git a/tests/lib_test.rs b/tests/lib_test.rs index 87d89f0..2741b94 100644 --- a/tests/lib_test.rs +++ b/tests/lib_test.rs @@ -207,6 +207,43 @@ mod lib_tests { assert!(is_text_file(&utf8_file, &[]).unwrap()); } + #[test] + fn test_typescript_files_not_treated_as_binary() { + // Test that .ts files (TypeScript) are correctly treated as text files + // and not confused with .ts video transport stream files + use yek::defaults::BINARY_FILE_EXTENSIONS; + + let dir = tempdir().unwrap(); + let ts_file = dir.path().join("example.ts"); + + // Create a typical TypeScript file with text content + fs::write( + &ts_file, + "interface User {\n name: string;\n age: number;\n}\n", + ) + .unwrap(); + + // Check that "ts" is NOT in the binary extensions list + assert!( + !BINARY_FILE_EXTENSIONS.contains(&"ts"), + "TypeScript extension 'ts' should not be in binary extensions list" + ); + + // Verify the file is detected as text + assert!( + is_text_file( + &ts_file, + BINARY_FILE_EXTENSIONS + .iter() + .map(|s| s.to_string()) + .collect::>() + .as_slice() + ) + .unwrap(), + "TypeScript files should be detected as text files" + ); + } + #[test] fn test_is_text_file_large_text_file() { let dir = tempdir().unwrap();