diff options
Diffstat (limited to 'app/assets/javascripts/editor/utils.js')
-rw-r--r-- | app/assets/javascripts/editor/utils.js | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/app/assets/javascripts/editor/utils.js b/app/assets/javascripts/editor/utils.js index df9d3f2b9fb..cea9a8971b7 100644 --- a/app/assets/javascripts/editor/utils.js +++ b/app/assets/javascripts/editor/utils.js @@ -16,17 +16,18 @@ export const setupEditorTheme = () => { monacoEditor.setTheme(theme ? themeName : DEFAULT_THEME); }; -export const getBlobLanguage = (blobPath) => { +export const getBlobLanguage = (path) => { const defaultLanguage = 'plaintext'; - if (!blobPath) { + if (!path) { return defaultLanguage; } - const ext = `.${blobPath.split('.').pop()}`; + const blobPath = path.split('/').pop(); + const ext = blobPath.includes('.') ? `.${blobPath.split('.').pop()}` : blobPath; const language = monacoLanguages .getLanguages() - .find((lang) => lang.extensions.indexOf(ext) !== -1); + .find((lang) => lang.extensions.indexOf(ext.toLowerCase()) !== -1); return language ? language.id : defaultLanguage; }; |