MCPcopy
hub / github.com/npmx-dev/npmx.dev / getLanguageFromPath

Function getLanguageFromPath

server/utils/code-highlight.ts:85–96  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

83 * Determine the language for syntax highlighting based on file path
84 */
85export function getLanguageFromPath(filePath: string): string {
86 const filename = filePath.split('/').pop() || ''
87
88 // Check for exact filename match first
89 if (FILENAME_MAP[filename]) {
90 return FILENAME_MAP[filename]
91 }
92
93 // Then check extension
94 const ext = filename.split('.').pop()?.toLowerCase() || ''
95 return EXTENSION_MAP[ext] || 'text'
96}
97
98/**
99 * Check if a module specifier is an npm package (not a relative/absolute path or Node built-in)

Callers 2

[...pkg].get.tsFile · 0.85
[...pkg].get.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected