From 96b750b36de19332e843418ea00917eb6b07df30 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 1 Jan 2026 10:00:16 +0000 Subject: [PATCH 1/4] Initial plan From e18c083594c39c964b52b48b379d975a93000a30 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 1 Jan 2026 10:06:44 +0000 Subject: [PATCH 2/4] Add test and fix for TypeScript .ts files incorrectly treated as binary Co-authored-by: mohsen1 <543633+mohsen1@users.noreply.github.com> --- src/defaults.rs | 2 +- tests/lib_test.rs | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/defaults.rs b/src/defaults.rs index c82ddcc..fb71da0 100644 --- a/src/defaults.rs +++ b/src/defaults.rs @@ -52,7 +52,7 @@ pub const BINARY_FILE_EXTENSIONS: &[&str] = &[ // Video "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..20df8e2 100644 --- a/tests/lib_test.rs +++ b/tests/lib_test.rs @@ -207,6 +207,35 @@ 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(); From fad99c6555685abb0c5408b4dfe2cf6dc9823a2e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 1 Jan 2026 10:13:44 +0000 Subject: [PATCH 3/4] Format code to pass linting checks Co-authored-by: mohsen1 <543633+mohsen1@users.noreply.github.com> --- tests/lib_test.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/lib_test.rs b/tests/lib_test.rs index 20df8e2..2741b94 100644 --- a/tests/lib_test.rs +++ b/tests/lib_test.rs @@ -231,7 +231,15 @@ mod lib_tests { // 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(), + 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" ); } From e367471ebfe949d398c3c895997ab326d941e24a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 1 Jan 2026 10:15:29 +0000 Subject: [PATCH 4/4] Add clarifying comment about .ts extension exclusion Co-authored-by: mohsen1 <543633+mohsen1@users.noreply.github.com> --- src/defaults.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/defaults.rs b/src/defaults.rs index fb71da0..fa068dc 100644 --- a/src/defaults.rs +++ b/src/defaults.rs @@ -51,6 +51,9 @@ 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", "mts", "m2ts", "vob", "rm", "rmvb", "asf", "ogv", "ogm", "webm", "dv", "divx", "xvid",