10000 :bug: Make sure there are no special characters in the project name w… · ct-js/ct-js@a9c2c71 · GitHub
[go: up one dir, main page]

Skip to content

Commit a9c2c71

Browse files
🐛 Make sure there are no special characters in the project name when creating one
Closes #543
1 parent 7f5a938 commit a9c2c71

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

app/data/i18n/English.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@
798798
"projectName": "Name:",
799799
"language": "Coding language:",
800800
"saveFolder": "Project's folder:",
801-
"input": "(letters and digits only)",
801+
"input": "(latin letters, underscore, and digits only)",
802802
"selectProjectFolder": "Select a folder in which to store your project",
803803
"nameError": "Wrong project name",
804804
"languageError": "You must specify a programming language"

app/data/i18n/Russian.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@
678678
"loading": "Подождите, коты набирают скорость света…",
679679
"loadingProject": "Загрузка проекта…",
680680
"newProject": {
681-
"input": "Имя проекта, латиница и цифры…",
681+
"input": "Латиница, нижний пробел и цифры…",
682682
"selectProjectFolder": "Выберите папку, в которой сохранить проект",
683683
"nameError": "Ошибка в имени проекта",
684684
"header": "Создать новый",

src/riotTags/project-selector.tag

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ project-selector
7070
placeholder="{voc.newProject.input}"
7171
pattern="[a-zA-Z_0-9]\\{1,\\}"
7272
oninput="{setProjectName}"
73+
value="{projectName}"
7374
width="20"
7475
maxlength="64"
7576
)
@@ -408,11 +409,13 @@ project-selector
408409
};
409410
this.setProjectName = e => {
410411
this.projectName = e.target.value.trim();
412+
this.projectName = this.projectName.replace(/[^a-zA-Z_0-9]/g, '');
413+
e.target.value = this.projectName;
411414
};
412415
/** A button listener for triggering a project creation process. */
413416
this.createProject = () => {
414417
const codename = this.projectName;
415-
if (codename.length === 0) {
418+
if (codename.length === 0 || /[^a-zA-Z_0-9]/.test(codename)) {
416419
alertify.error(this.voc.newProject.nameError);
417420
return;
418421
}

0 commit comments

Comments
 (0)
0