MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / resolveEditorLanguage

Function resolveEditorLanguage

frontend/src/utils/file.ts:180–202  ·  view source on GitHub ↗
(path: string, extension = '', name = '')

Source from the content-addressed store, hash-verified

178};
179
180export const resolveEditorLanguage = (path: string, extension = '', name = '') => {
181 if (isSpecialEditorFileName(name)) {
182 return 'dockerfile';
183 }
184
185 const candidates = [extension, path.split('/').pop() || '']
186 .map((value) => normalizeEditorExtension(value))
187 .filter(Boolean);
188
189 for (const ext of candidates) {
190 const language = editorLanguages.get(ext);
191 if (language) {
192 return language;
193 }
194 }
195
196 const fileName = path.split('/').pop() || '';
197 if (isSpecialEditorFileName(fileName)) {
198 return 'dockerfile';
199 }
200
201 return 'yaml';
202};

Callers

nothing calls this directly

Calls 3

isSpecialEditorFileNameFunction · 0.85
normalizeEditorExtensionFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected