Skip to content
This repository has been archived by the owner. It is now read-only.

Commit 4439111

Browse files
committed
checking for null before replacing
1 parent 6db1d4a commit 4439111

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

app/main.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,12 +473,14 @@ var appConfig = {
473473

474474
// create a new file and save it in the project path
475475
newFile: function(basepath) {
476-
var title = prompt('Choose a file name and type: \nSupported types: ' + this.fileTypes.toString()).replace(/ /g,'');
477-
var dotSplit = title.split(".");
478-
var re = /(?:\.([^.]+))?$/;
476+
var title = prompt('Choose a file name and type: \nSupported types: ' + this.fileTypes.toString());
479477

480478
if (!title) return false;
481479

480+
title = title.replace(/ /g,'');
481+
var dotSplit = title.split(".");
482+
var re = /(?:\.([^.]+))?$/;
483+
482484
if (this.fileTypes.indexOf(re.exec(title)[1]) < 0 || (dotSplit.length > 2)){
483485
window.alert("unsupported/improper file type selected.\nAutomaticallly adding a .js extension");
484486
title = dotSplit[0] + '.js';

0 commit comments

Comments
 (0)