diff --git a/moon/apps/web/components/DiffView/FileDiff.tsx b/moon/apps/web/components/DiffView/FileDiff.tsx
index 257232761..84b46aa6f 100644
--- a/moon/apps/web/components/DiffView/FileDiff.tsx
+++ b/moon/apps/web/components/DiffView/FileDiff.tsx
@@ -71,7 +71,7 @@ export default function FileDiff({ diffs }: { diffs: string }) {
file: { path: string; lang: string; diff: string };
instance: DiffFile;
}) => {
- if (file.lang === 'plaintext') {
+ if (file.lang === 'binary') {
return
Binary file
}
diff --git a/moon/apps/web/components/DiffView/parsedDiffs.ts b/moon/apps/web/components/DiffView/parsedDiffs.ts
index 32d48f792..1f35f81cd 100644
--- a/moon/apps/web/components/DiffView/parsedDiffs.ts
+++ b/moon/apps/web/components/DiffView/parsedDiffs.ts
@@ -1,31 +1,49 @@
const extensionToLangMap: Record = {
- ".ts": "typescript",
- ".tsx": "typescriptreact",
- ".js": "javascript",
- ".jsx": "javascriptreact",
- ".json": "json",
- ".md": "markdown",
- ".py": "python",
- ".rs": "rust",
- ".cpp": "cpp",
- ".c": "c",
- ".h": "cpp",
- ".java": "java",
- ".go": "go",
- ".sh": "bash",
- ".yml": "yaml",
- ".yaml": "yaml",
- ".css": "css",
- ".scss": "scss",
- ".html": "html",
- ".vue": "vue",
- ".toml": "toml",
-};
+ '.ts': 'typescript',
+ '.tsx': 'tsx',
+ '.js': 'javascript',
+ '.jsx': 'jsx',
+ '.json': 'json',
+ '.md': 'markdown',
+ '.py': 'python',
+ '.rs': 'rust',
+ '.cpp': 'cpp',
+ '.c': 'c',
+ '.h': 'cpp',
+ '.java': 'java',
+ '.go': 'go',
+ '.sh': 'bash',
+ '.yml': 'yaml',
+ '.yaml': 'yaml',
+ '.css': 'css',
+ '.scss': 'scss',
+ '.html': 'html',
+ '.vue': 'vue',
+ '.toml': 'toml',
+ 'dockerfile': 'dockerfile',
+ '.dockerfile': 'dockerfile',
+ 'license-mit': 'plaintext',
+ 'buck': 'plaintext',
+ '.gitignore': 'plaintext',
+ '.env': 'plaintext',
+ 'license-third-party': 'plaintext',
+ 'license-apache': 'plaintext',
+}
function getLangFromPath(path: string): string {
- const ext = path.match(/\.[^./\\]+$/)?.[0]?.toLowerCase();
+ const extMatch = path.match(/\.[^./\\]+$/);
- return ext ? extensionToLangMap[ext] ?? "plaintext" : "plaintext";
+ if(extMatch) {
+ return extensionToLangMap[extMatch[0].toLowerCase()] ?? "binary";
+ } else {
+ const lastPart = path.split('/').pop()?.toLowerCase();
+
+ if(lastPart) {
+ return extensionToLangMap[lastPart] ?? "binary";
+ }
+ }
+
+ return "binary";
}
export function parsedDiffs(diffText: string): { path: string; lang: string; diff: string }[] {
@@ -52,7 +70,7 @@ export function parsedDiffs(diffText: string): { path: string; lang: string; dif
}
}
- if (getLangFromPath(path) === "plaintext") {
+ if (getLangFromPath(path) === "binary") {
return {
path,
lang: getLangFromPath(path),