From 808a924bcee9c4f1432c2d0411a026efe5e4ed96 Mon Sep 17 00:00:00 2001 From: Rafael Velazco Date: Fri, 20 Oct 2023 13:04:18 -0400 Subject: [PATCH] fix(core): Edit Contentlet: Allow User Write Code #26045 * fix: SonarQube regex warning * warning: avoid use RegEx * warning: avoid use RegEx --- .../dot-binary-field-editor.component.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core-web/libs/contenttype-fields/src/lib/fields/binary-field/components/dot-binary-field-editor/dot-binary-field-editor.component.ts b/core-web/libs/contenttype-fields/src/lib/fields/binary-field/components/dot-binary-field-editor/dot-binary-field-editor.component.ts index f780c97aeb2a..63bd3d093f9d 100644 --- a/core-web/libs/contenttype-fields/src/lib/fields/binary-field/components/dot-binary-field-editor/dot-binary-field-editor.component.ts +++ b/core-web/libs/contenttype-fields/src/lib/fields/binary-field/components/dot-binary-field-editor/dot-binary-field-editor.component.ts @@ -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('') }); @@ -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 }); }