Merge pull request #2763 from ethereum/fixSolMode

Better file type extraction
pull/1/head
yann300 5 years ago committed by GitHub
commit 4d5159fe8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      src/app/editor/editor.js

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

Loading…
Cancel
Save