MCPcopy
hub / github.com/codeaashu/claude-code / detectLanguage

Function detectLanguage

web/lib/fileViewerStore.ts:53–82  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

51}
52
53export function detectLanguage(filePath: string): string {
54 const filename = filePath.split("/").pop()?.toLowerCase() ?? "";
55 if (filename === "dockerfile") return "dockerfile";
56 if (filename === "makefile" || filename === "gnumakefile") return "makefile";
57
58 const ext = filename.split(".").pop() ?? "";
59 const map: Record<string, string> = {
60 ts: "typescript", tsx: "tsx", js: "javascript", jsx: "jsx",
61 mjs: "javascript", cjs: "javascript",
62 py: "python", rs: "rust", go: "go",
63 css: "css", scss: "scss", less: "less",
64 html: "html", htm: "html",
65 json: "json", jsonc: "json",
66 md: "markdown", mdx: "markdown",
67 sh: "bash", bash: "bash", zsh: "bash",
68 yml: "yaml", yaml: "yaml",
69 toml: "toml", sql: "sql",
70 graphql: "graphql", gql: "graphql",
71 rb: "ruby", java: "java",
72 c: "c", cpp: "cpp", cc: "cpp", cxx: "cpp",
73 h: "c", hpp: "cpp",
74 cs: "csharp", php: "php",
75 swift: "swift", kt: "kotlin",
76 r: "r", scala: "scala",
77 ex: "elixir", exs: "elixir",
78 vue: "vue", svelte: "svelte",
79 xml: "xml",
80 };
81 return map[ext] ?? "text";
82}
83
84function getFilename(filePath: string): string {
85 return filePath.split("/").pop() ?? filePath;

Callers 1

fileViewerStore.tsFile · 0.70

Calls 1

popMethod · 0.80

Tested by

no test coverage detected