Spaces:
Runtime error
Runtime error
Update src/lib/sb-file-uploader-hoc.jsx
Browse files
src/lib/sb-file-uploader-hoc.jsx
CHANGED
|
@@ -104,7 +104,7 @@ const SBFileUploaderHOC = function (WrappedComponent) {
|
|
| 104 |
} else {
|
| 105 |
// create <input> element and add it to DOM
|
| 106 |
this.inputElement = document.createElement('input');
|
| 107 |
-
this.inputElement.accept = '.sb,.sb2,.sb3,.pm,.pmp';
|
| 108 |
this.inputElement.style = 'display: none;';
|
| 109 |
this.inputElement.type = 'file';
|
| 110 |
this.inputElement.onchange = this.handleChange; // connects to step 3
|
|
@@ -141,7 +141,7 @@ const SBFileUploaderHOC = function (WrappedComponent) {
|
|
| 141 |
// Don't update file handle until after confirming replace.
|
| 142 |
const handle = thisFileInput.handle;
|
| 143 |
if (handle) {
|
| 144 |
-
if (this.fileToUpload.name.endsWith('.pm') || this.fileToUpload.name.endsWith('.pmp')) {
|
| 145 |
this.props.onSetFileHandle(handle);
|
| 146 |
} else {
|
| 147 |
this.props.onSetFileHandle(null);
|
|
@@ -178,7 +178,7 @@ const SBFileUploaderHOC = function (WrappedComponent) {
|
|
| 178 |
if (!fileInputFilename) return '';
|
| 179 |
// only parse title with valid scratch project extensions
|
| 180 |
// (.sb, .sb2, and .sb3)
|
| 181 |
-
const matches = fileInputFilename.match(/^(.*)(\.sb[23]?|\.pm|\.pmp)$/);
|
| 182 |
if (!matches) return '';
|
| 183 |
return matches[1].substring(0, 100); // truncate project title to max 100 chars
|
| 184 |
}
|
|
|
|
| 104 |
} else {
|
| 105 |
// create <input> element and add it to DOM
|
| 106 |
this.inputElement = document.createElement('input');
|
| 107 |
+
this.inputElement.accept = '.sb,.sb2,.sb3,.pm,.pmp,.s4s.txt';
|
| 108 |
this.inputElement.style = 'display: none;';
|
| 109 |
this.inputElement.type = 'file';
|
| 110 |
this.inputElement.onchange = this.handleChange; // connects to step 3
|
|
|
|
| 141 |
// Don't update file handle until after confirming replace.
|
| 142 |
const handle = thisFileInput.handle;
|
| 143 |
if (handle) {
|
| 144 |
+
if (this.fileToUpload.name.endsWith('.pm') || this.fileToUpload.name.endsWith('.s4s.txt') || this.fileToUpload.name.endsWith('.pmp')) {
|
| 145 |
this.props.onSetFileHandle(handle);
|
| 146 |
} else {
|
| 147 |
this.props.onSetFileHandle(null);
|
|
|
|
| 178 |
if (!fileInputFilename) return '';
|
| 179 |
// only parse title with valid scratch project extensions
|
| 180 |
// (.sb, .sb2, and .sb3)
|
| 181 |
+
const matches = fileInputFilename.match(/^(.*)(\.sb[23]?|\.pm|\.pmp|\.s4s.txt)$/);
|
| 182 |
if (!matches) return '';
|
| 183 |
return matches[1].substring(0, 100); // truncate project title to max 100 chars
|
| 184 |
}
|