diff options
author | Eric Eastwood <contact@ericeastwood.com> | 2017-08-11 19:31:12 +0300 |
---|---|---|
committer | Eric Eastwood <contact@ericeastwood.com> | 2017-08-14 19:11:01 +0300 |
commit | 5bf22c8607020368558eff30d207a49631f486ee (patch) | |
tree | 97f5d14661e5ea22edffbfcb7270eb61d1130ea0 /app/assets | |
parent | fd8388d85b0aaf098d8e89c04bc32936a8e66389 (diff) |
Add shared getFileExtension helper method
Fix
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12198#note_37146854
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); }, |