Fix regex for extracting the project title from a .sb file

This commit is contained in:
Karishma Chadha committed 2018-12-25 13:17:52 -05:00
1 parent daeec8fa0d
commit 6b2cf976f6
1 file changed
+3 -2
+3 -2
View File
@@ -80,8 +80,9 @@ class SBFileUploader extends React.Component {
}
getProjectTitleFromFilename (fileInputFilename) {
if (!fileInputFilename) return '';
// only parse title from files like "filename.sb2" or "filename.sb3"
const matches = fileInputFilename.match(/^(.*)\.sb[23]$/);
// only parse title with valid scratch project extensions
// (.sb, .sb2, and .sb3)
const matches = fileInputFilename.match(/^(.*)\.sb[23]?$/);
if (!matches) return '';
return matches[1].substring(0, 100); // truncate project title to max 100 chars
}