diff --git a/client/modules/IDE/components/FileNode.jsx b/client/modules/IDE/components/FileNode.jsx index a9c4f0a7..1b28bd4e 100644 --- a/client/modules/IDE/components/FileNode.jsx +++ b/client/modules/IDE/components/FileNode.jsx @@ -67,13 +67,15 @@ export class FileNode extends React.Component { validateFileName() { const oldFileExtension = this.originalFileName.match(/\.[0-9a-z]+$/i); const newFileExtension = this.props.name.match(/\.[0-9a-z]+$/i); + const hasPeriod = this.props.name.match(/\.+/); const newFileName = this.props.name; const hasNoExtension = oldFileExtension && !newFileExtension; - const notSameExtension = oldFileExtension && newFileExtension && - oldFileExtension[0].toLowerCase() !== newFileExtension[0].toLowerCase(); + const hasExtensionIfFolder = this.props.fileType === 'folder' && hasPeriod; + const notSameExtension = oldFileExtension && newFileExtension + && oldFileExtension[0].toLowerCase() !== newFileExtension[0].toLowerCase(); const hasEmptyFilename = newFileName === ''; const hasOnlyExtension = newFileExtension && newFileName === newFileExtension[0]; - if (hasEmptyFilename || hasNoExtension || notSameExtension || hasOnlyExtension) { + if (hasEmptyFilename || hasNoExtension || notSameExtension || hasOnlyExtension || hasExtensionIfFolder) { this.props.updateFileName(this.props.id, this.originalFileName); } } diff --git a/client/modules/IDE/components/NewFolderModal.jsx b/client/modules/IDE/components/NewFolderModal.jsx index 4d1e714c..60483ce8 100644 --- a/client/modules/IDE/components/NewFolderModal.jsx +++ b/client/modules/IDE/components/NewFolderModal.jsx @@ -38,6 +38,8 @@ function validate(formProps) { errors.name = 'Please enter a name'; } else if (formProps.name.trim().length === 0) { errors.name = 'Folder name cannot contain only spaces'; + } else if (formProps.name.match(/\.+/i)) { + errors.name = 'Folder name cannot contain an extension'; } return errors;