diff --git a/src/app/editor/editor.js b/src/app/editor/editor.js index d418e48c16..f882e99a9e 100644 --- a/src/app/editor/editor.js +++ b/src/app/editor/editor.js @@ -243,13 +243,11 @@ class Editor extends Plugin { * @param {string} path Path of the file */ _getMode (path) { - let ext = path.indexOf('.') !== -1 ? /[^.]+/.exec(path) : null - if (ext) { - ext = path.replace(ext[0] + '.', '') // we get - } else ext = 'txt' - ext = ext.split('#') - if (!ext.length) return this.modes['txt'] - ext = ext[0] + if (!path) return this.modes['txt'] + const root = path.split('#')[0].split('?')[0] + let ext = root.indexOf('.') !== -1 ? /[^.]+$/.exec(root) : null + if (ext) ext = ext[0] + else ext = 'txt' return ext && this.modes[ext] ? this.modes[ext] : this.modes['txt'] }