remote-files: server-side check for json extension

This commit is contained in:
jean-emmanuel 2019-04-02 09:51:18 +02:00
parent 2523bbf05c
commit bffdf8917b
2 changed files with 6 additions and 2 deletions

View file

@ -175,7 +175,7 @@ module.exports = {
var files = [],
path = ''
var extRe = options.extension ? new RegExp('.*\\.' + options.extension) : /.*/
var extRe = options.extension ? new RegExp('.*\\.' + options.extension + '$') : /.*/
if (save) {
saveInput.addEventListener('change', ()=>{

View file

@ -70,7 +70,7 @@ module.exports = {
sessionSetPath: function(data, clientId) {
if (Array.isArray(data.path)) path = path.resolve(...data.path)
if (Array.isArray(data.path)) data.path = path.resolve(...data.path)
ipc.clients[clientId].sessionPath = data.path
@ -175,6 +175,10 @@ module.exports = {
sessionSave: function(data, clientId) {
if (Array.isArray(data.path)) data.path = path.resolve(...data.path)
if (!path.basename(data.path).match(/.*\.json$/)) return console.error('Sessions must be saved as .json files')
module.exports.fileSave(data, clientId, true, ()=>{
console.log('Session file saved in '+ data.path)