for #989, files cannot be renamed to empty string

This commit is contained in:
Rachel Lim 2019-06-30 19:41:27 -04:00 committed by Cassie Tarakajian
parent f6416738ae
commit b94ca8a52d

View file

@ -67,6 +67,7 @@ export class FileNode extends React.Component {
validateFileName() { validateFileName() {
const oldFileExtension = this.originalFileName.match(/\.[0-9a-z]+$/i); const oldFileExtension = this.originalFileName.match(/\.[0-9a-z]+$/i);
const newFileExtension = this.props.name.match(/\.[0-9a-z]+$/i); const newFileExtension = this.props.name.match(/\.[0-9a-z]+$/i);
const newFileName = this.props.name;
if (oldFileExtension && !newFileExtension) { if (oldFileExtension && !newFileExtension) {
this.props.updateFileName(this.props.id, this.originalFileName); this.props.updateFileName(this.props.id, this.originalFileName);
} }
@ -77,6 +78,12 @@ export class FileNode extends React.Component {
) { ) {
this.props.updateFileName(this.props.id, this.originalFileName); this.props.updateFileName(this.props.id, this.originalFileName);
} }
if (newFileName === '') {
this.props.updateFileName(this.props.id, this.originalFileName);
}
if (newFileName === newFileExtension[0]) {
this.props.updateFileName(this.props.id, this.originalFileName);
}
} }
toggleFileOptions(e) { toggleFileOptions(e) {