Skip to content

Commit

Permalink
fix(core): Edit Contentlet: Allow User Write Code #26045
Browse files Browse the repository at this point in the history
* fix: SonarQube regex warning

* warning: avoid use RegEx

* warning: avoid use RegEx
  • Loading branch information
rjvelazco authored Oct 20, 2023
1 parent 423db1f commit 808a924
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class DotBinaryFieldEditorComponent implements OnInit, AfterViewInit {
private invalidFileMessage = '';
private editor: monaco.editor.IStandaloneCodeEditor;
readonly form = new FormGroup({
name: new FormControl('', [Validators.required, Validators.pattern(/^.+\..+$/)]),
name: new FormControl('', [Validators.required, Validators.pattern(/^[^.]+\.[^.]+$/)]),
content: new FormControl('')
});

Expand Down Expand Up @@ -142,12 +142,12 @@ export class DotBinaryFieldEditorComponent implements OnInit, AfterViewInit {
}

private setEditorLanguage(fileName: string = '') {
const fileExtension = fileName?.split('.').pop();
const fileExtension = fileName?.includes('.') ? fileName.split('.').pop() : '';
const { id, mimetypes, extensions } = this.getLanguage(fileExtension) || {};
this.mimeType = mimetypes?.[0];
this.extension = extensions?.[0];

if (!this.isValidType()) {
if (fileExtension && !this.isValidType()) {
this.name.setErrors({ invalidExtension: this.invalidFileMessage });
}

Expand Down

0 comments on commit 808a924

Please sign in to comment.