Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Comment on lines 53 to +56
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The multi-line comment should follow Rust's convention of using // for each line rather than placing it as a separate block before the array line. This would be more consistent with the single-line comments used elsewhere in this file (e.g., line 10, 11, 18, etc.).

Suggested change
// 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.
// Video (.ts MPEG transport stream is intentionally excluded to avoid conflicts
// with TypeScript files; actual binary .ts files are detected via content inspection)

Copilot uses AI. Check for mistakes.
"mp4", "m4v", "mov", "avi", "wmv", "mkv", "flv", "f4v", "f4p", "f4a", "f4b", "3gp",
"3g2", "mpeg", "mpg", "mpe", "m1v", "m2v", "ts", "mts", "m2ts", "vob", "rm", "rmvb",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot ts can be a video if it's binary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct - the content inspection in is_text_file() (src/lib.rs:44-60) reads the first 8KB of each file and uses the content_inspector crate to detect binary content. So binary .ts video files will still be caught and skipped, while TypeScript text files will be processed.

"3g2", "mpeg", "mpg", "mpe", "m1v", "m2v", "mts", "m2ts", "vob", "rm", "rmvb",
"asf", "ogv", "ogm", "webm", "dv", "divx", "xvid",

// Font Files
Expand Down
37 changes: 37 additions & 0 deletions tests/lib_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<_>>()
.as_slice()
)
.unwrap(),
"TypeScript files should be detected as text files"
);
}

#[test]
fn test_is_text_file_large_text_file() {
let dir = tempdir().unwrap();
Expand Down
Loading