Repository: angular/angular
File: adev/src/app/editor/code-editor/code-editor.component.ts (TypeScript)

Code before:
    const renameFileInputValue = renameFileInput.nativeElement.value;

    if (this.valideteFileName(renameFileInputValue)) {
      // src is hidden from users, here we manually add it to the new filename
      const newFile = 'src/' + renameFileInputValue;

      if (this.files().find(({filename}) => filename.includes(newFile))) {
        alert('File name already exists');
        return;
      }

      await this.codeMirrorEditor.renameFile(oldPath, newFile);
    }

    this.isRenamingFile.set(false);
  }

  protected async createFile(event?: SubmitEvent) {
    const fileInput = this.createFileInputRef();
    if (!fileInput) return;

    event?.preventDefault();

    const newFileInputValue = fileInput.nativeElement.value;

    if (this.valideteFileName(newFileInputValue)) {
      // src is hidden from users, here we manually add it to the new filename
      const newFile = 'src/' + newFileInputValue;

      if (this.files().find(({filename}) => filename.includes(newFile))) {
        alert('File already exists');
        return;
      }

      await this.codeMirrorEditor.createFile(newFile);
    }

    this.isCreatingFile.set(false);
  }

  private valideteFileName(fileName: string): boolean {
    if (!fileName) {
      return false;
    }
    if (fileName.split('/').pop()?.indexOf('.') === 0) {
      alert('File must contain a name.');
      return false;
    }
    if (fileName.includes('..')) {
      alert('File name can not contain ".."');
      return false;

Review comment (suggestion):
```suggestion
    if (this.validateFileName(newFileInputValue)) {
```

Code after:
    const renameFileInputValue = renameFileInput.nativeElement.value;

    if (this.validateFileName(renameFileInputValue)) {
      // src is hidden from users, here we manually add it to the new filename
      const newFile = 'src/' + renameFileInputValue;

      if (this.files().find(({filename}) => filename.includes(newFile))) {
        alert('File name already exists');
        return;
      }

      await this.codeMirrorEditor.renameFile(oldPath, newFile);
    }

    this.isRenamingFile.set(false);
  }

  protected async createFile(event?: SubmitEvent) {
    const fileInput = this.createFileInputRef();
    if (!fileInput) return;

    event?.preventDefault();

    const newFileInputValue = fileInput.nativeElement.value;

    if (this.validateFileName(newFileInputValue)) {
      // src is hidden from users, here we manually add it to the new filename
      const newFile = 'src/' + newFileInputValue;

      if (this.files().find(({filename}) => filename.includes(newFile))) {
        alert('File already exists');
        return;
      }

      await this.codeMirrorEditor.createFile(newFile);
    }

    this.isCreatingFile.set(false);
  }

  private validateFileName(fileName: string): boolean {
    if (!fileName) {
      return false;
    }
    if (fileName.split('/').pop()?.indexOf('.') === 0) {
      alert('File must contain a name.');
      return false;
    }
    if (fileName.includes('..')) {
      alert('File name can not contain ".."');
      return false;