From 5d019137fa544d1313d8d498b940ac3046b3c695 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 9 Feb 2025 17:43:25 +0100 Subject: [PATCH 1/2] test: add test for .ts file --- src/services/import/mime.spec.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/services/import/mime.spec.ts b/src/services/import/mime.spec.ts index acebd94f7..299bc3e2d 100644 --- a/src/services/import/mime.spec.ts +++ b/src/services/import/mime.spec.ts @@ -12,12 +12,17 @@ describe("#getMime", () => { ], [ - "File extension that is defined in EXTENSION_TO_MIME", + "File extension ('.py') that is defined in EXTENSION_TO_MIME", ["test.py"], "text/x-python" ], [ - "File extension with inconsisten capitalization that is defined in EXTENSION_TO_MIME", + "File extension ('.ts') that is defined in EXTENSION_TO_MIME", + ["test.ts"], "text/x-typescript" + ], + + [ + "File extension with inconsistent capitalization that is defined in EXTENSION_TO_MIME", ["test.gRoOvY"], "text/x-groovy" ], From 2d1381b4f862d50ad8d52664cb07b63aaff73d83 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 9 Feb 2025 17:45:15 +0100 Subject: [PATCH 2/2] fix(import/mime): fix TypeScript handling .ts file are now treated as code type with text/x-typescript as MIME type fixes #1142 --- src/services/import/mime.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/services/import/mime.ts b/src/services/import/mime.ts index 9930c9010..339f3b468 100644 --- a/src/services/import/mime.ts +++ b/src/services/import/mime.ts @@ -37,6 +37,7 @@ const CODE_MIME_TYPES = new Set([ "text/x-sql", "text/x-stex", "text/x-swift", + "text/x-typescript", "text/x-yaml" ]); @@ -65,7 +66,8 @@ const EXTENSION_TO_MIME = new Map([ [".py", "text/x-python"], [".rb", "text/x-ruby"], [".scala", "text/x-scala"], - [".swift", "text/x-swift"] + [".swift", "text/x-swift"], + [".ts", "text/x-typescript"] ]); /** @returns false if MIME is not detected */