Merge pull request #1486 from Gingeh/export-extensions

Check for a valid file extension when exporting, fixes #1485
This commit is contained in:
JannisX11 2022-07-19 22:31:00 +02:00 committed by GitHub
commit 94e6e31ab6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -275,7 +275,8 @@ Object.assign(Blockbench, {
*/
if (Blockbench.isWeb) {
var file_name = options.name || 'file';
if (options.extensions && file_name.substr(-options.extensions[0].length) != options.extensions[0]) {
var extension = pathToExtension(file_name);
if (options.extensions instanceof Array && !options.extensions.includes(extension) && options.extensions[0]) {
file_name += '.' + options.extensions[0];
}
if (options.custom_writer) {
@ -326,7 +327,7 @@ Object.assign(Blockbench, {
StateMemory.save('dialog_paths')
}
var extension = pathToExtension(file_path);
if (!extension && options.extensions && options.extensions[0]) {
if (options.extensions instanceof Array && !options.extensions.includes(extension) && options.extensions[0]) {
file_path += '.'+options.extensions[0]
}
Blockbench.writeFile(file_path, options, cb)