refactor so that you can disable all editable extensions, including .txt

This commit is contained in:
Milos Stojanovic
2020-11-03 09:16:22 +01:00
parent e38a1d3909
commit 832b219132
2 changed files with 5 additions and 2 deletions

View File

@@ -2,6 +2,8 @@
## Upcoming... ## Upcoming...
* Fixes #153 (Thanks @Gui13)
## 7.4.6 - 2020-11-02 ## 7.4.6 - 2020-11-02
* New feature - upload folder with drag&drop, fixes #25 (Thanks @ahaenggli) * New feature - upload folder with drag&drop, fixes #25 (Thanks @ahaenggli)

View File

@@ -3,6 +3,7 @@ import moment from 'moment'
import store from '../store.js' import store from '../store.js'
import api from '../api/api' import api from '../api/api'
import { Base64 } from 'js-base64' import { Base64 } from 'js-base64'
import _ from 'lodash'
import english from '../translations/english' import english from '../translations/english'
import spanish from '../translations/spanish' import spanish from '../translations/spanish'
@@ -142,13 +143,13 @@ const funcs = {
return this.isText(name) || this.isImage(name) return this.isText(name) || this.isImage(name)
}, },
isText(name) { isText(name) {
return this.hasExtension(name, (store.state.config.editable && store.state.config.editable.length > 0) ? store.state.config.editable : ['.txt']) return this.hasExtension(name, store.state.config.editable)
}, },
isImage(name) { isImage(name) {
return this.hasExtension(name, ['.jpg', '.jpeg', '.gif', '.png', '.bmp', '.svg', '.tiff', '.tif']) return this.hasExtension(name, ['.jpg', '.jpeg', '.gif', '.png', '.bmp', '.svg', '.tiff', '.tif'])
}, },
hasExtension(name, exts) { hasExtension(name, exts) {
return (new RegExp('(' + exts.join('|').replace(/\./g, '\\.') + ')$', 'i')).test(name) return !_.isEmpty(exts) && (new RegExp('(' + exts.join('|').replace(/\./g, '\\.') + ')$', 'i')).test(name)
}, },
capitalize(string) { capitalize(string) {
return string.charAt(0).toUpperCase() + string.slice(1) return string.charAt(0).toUpperCase() + string.slice(1)