From 6b2cf976f6f8daef4f803f2ddc658785b3403b0f Mon Sep 17 00:00:00 2001 From: Karishma Chadha Date: Tue, 25 Dec 2018 13:17:52 -0500 Subject: [PATCH] Fix regex for extracting the project title from a .sb file --- src/containers/sb-file-uploader.jsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/containers/sb-file-uploader.jsx b/src/containers/sb-file-uploader.jsx index 8eeb04e4d..66d33c13c 100644 --- a/src/containers/sb-file-uploader.jsx +++ b/src/containers/sb-file-uploader.jsx @@ -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 }