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 }); }