summaryrefslogtreecommitdiff
path: root/packages/core/src/utils/fileUtils.ts
diff options
context:
space:
mode:
authorTommaso Sciortino <[email protected]>2025-07-01 16:05:33 -0700
committerGitHub <[email protected]>2025-07-01 23:05:33 +0000
commit82afc753505c5a83770a9aa66b81a43d906ff9de (patch)
tree3ce378a4e8782b3374ca4ad0feb0f52a9e1471f3 /packages/core/src/utils/fileUtils.ts
parent383306e17ea8bf88c8f7bc24a4873246af3cc983 (diff)
Special case mime type for ts file. (#2902)
Diffstat (limited to 'packages/core/src/utils/fileUtils.ts')
-rw-r--r--packages/core/src/utils/fileUtils.ts8
1 files changed, 7 insertions, 1 deletions
diff --git a/packages/core/src/utils/fileUtils.ts b/packages/core/src/utils/fileUtils.ts
index 5a05d513..72f29436 100644
--- a/packages/core/src/utils/fileUtils.ts
+++ b/packages/core/src/utils/fileUtils.ts
@@ -100,8 +100,14 @@ export function detectFileType(
filePath: string,
): 'text' | 'image' | 'pdf' | 'audio' | 'video' | 'binary' {
const ext = path.extname(filePath).toLowerCase();
- const lookedUpMimeType = mime.lookup(filePath); // Returns false if not found, or the mime type string
+ // The mimetype for "ts" is MPEG transport stream (a video format) but we want
+ // to assume these are typescript files instead.
+ if (ext === '.ts') {
+ return 'text';
+ }
+
+ const lookedUpMimeType = mime.lookup(filePath); // Returns false if not found, or the mime type string
if (lookedUpMimeType) {
if (lookedUpMimeType.startsWith('image/')) {
return 'image';