WARM-IDE: Add check for invalid project name when creating new project (#1461)
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
import fileSystem = require('fs');
|
||||
import vscode = require('vscode');
|
||||
import path = require('path');
|
||||
import os = require('os');
|
||||
|
||||
/**
|
||||
*
|
||||
@ -94,3 +95,26 @@ export function CheckIfDirectoryExist(path: string): boolean {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function checkFolderName(folderName: string) {
|
||||
let invalidCharacterArr: string[] = [];
|
||||
var valid = true;
|
||||
|
||||
if (folderName.length > 255) {
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if (os.platform() === 'win32') {
|
||||
invalidCharacterArr = ['\\', '/', ':', '?', '*', '"', '|', '<', '>'];
|
||||
} else if (os.platform() === 'linux' || os.platform() === 'darwin') {
|
||||
invalidCharacterArr = ['/'];
|
||||
}
|
||||
|
||||
invalidCharacterArr.forEach(function (c) {
|
||||
if (folderName.indexOf(c) !== -1) {
|
||||
valid = false;
|
||||
}
|
||||
});
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user