diff options
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/repo/helpers/repo_helper.js | 6 | ||||
-rw-r--r-- | app/assets/javascripts/repo/services/repo_service.js | 3 |
2 files changed, 7 insertions, 2 deletions
diff --git a/app/assets/javascripts/repo/helpers/repo_helper.js b/app/assets/javascripts/repo/helpers/repo_helper.js index 9a36ec97de2..17aaa0e1584 100644 --- a/app/assets/javascripts/repo/helpers/repo_helper.js +++ b/app/assets/javascripts/repo/helpers/repo_helper.js @@ -33,12 +33,16 @@ const RepoHelper = { ? window.performance : Date, + getFileExtension(fileName) { + return fileName.split('.').pop(); + }, + getBranch() { return $('button.dropdown-menu-toggle').attr('data-ref'); }, getLanguageIDForFile(file, langs) { - const ext = file.name.split('.').pop(); + const ext = RepoHelper.getFileExtension(file.name); const foundLang = RepoHelper.findLanguage(ext, langs); return foundLang ? foundLang.id : 'plaintext'; diff --git a/app/assets/javascripts/repo/services/repo_service.js b/app/assets/javascripts/repo/services/repo_service.js index bebe4e42fe1..17578f3bbf3 100644 --- a/app/assets/javascripts/repo/services/repo_service.js +++ b/app/assets/javascripts/repo/services/repo_service.js @@ -2,6 +2,7 @@ import axios from 'axios'; import Store from '../stores/repo_store'; import Api from '../../api'; +import Helper from '../helpers/repo_helper'; const RepoService = { url: '', @@ -37,7 +38,7 @@ const RepoService = { }, urlIsRichBlob(url = this.url) { - const extension = url.split('.').pop(); + const extension = Helper.getFileExtension(url); return this.richExtensionRegExp.test(extension); }, |