Handle whitespace in file name validation

This commit is contained in:
Cassie Tarakajian 2020-04-16 16:22:59 -04:00
parent 72622df155
commit 2c9fd982d0

View file

@ -116,8 +116,8 @@ export class FileNode extends React.Component {
const hasExtensionIfFolder = this.props.fileType === 'folder' && hasPeriod; const hasExtensionIfFolder = this.props.fileType === 'folder' && hasPeriod;
const notSameExtension = oldFileExtension && newFileExtension const notSameExtension = oldFileExtension && newFileExtension
&& oldFileExtension[0].toLowerCase() !== newFileExtension[0].toLowerCase(); && oldFileExtension[0].toLowerCase() !== newFileExtension[0].toLowerCase();
const hasEmptyFilename = updatedName === ''; const hasEmptyFilename = updatedName.trim() === '';
const hasOnlyExtension = newFileExtension && updatedName === newFileExtension[0]; const hasOnlyExtension = newFileExtension && updatedName.trim() === newFileExtension[0];
if (hasEmptyFilename || hasNoExtension || notSameExtension || hasOnlyExtension || hasExtensionIfFolder) { if (hasEmptyFilename || hasNoExtension || notSameExtension || hasOnlyExtension || hasExtensionIfFolder) {
this.setUpdatedName(currentName); this.setUpdatedName(currentName);
} else { } else {