fix: corregge drag & drop e riconoscimento estensioni CAD versionate
This commit is contained in:
@@ -1,15 +1,21 @@
|
||||
const path = require('path');
|
||||
|
||||
function getCadType(filename) {
|
||||
const baseName = path.basename(filename).toLowerCase();
|
||||
const match = baseName.match(/\.(prt|asm|drw|dwr)(?:\.\d+)?$/);
|
||||
return match ? match[1] : null;
|
||||
}
|
||||
|
||||
function findDestination(filename, config) {
|
||||
const ext = path.extname(filename).slice(1).toLowerCase();
|
||||
const cadType = getCadType(filename);
|
||||
const globalDestination = typeof config?.destination === 'string' ? config.destination.trim() : '';
|
||||
|
||||
if (globalDestination && ['prt', 'asm', 'dwr'].includes(ext)) {
|
||||
if (globalDestination && cadType) {
|
||||
return globalDestination;
|
||||
}
|
||||
|
||||
for (const rule of config.rules || []) {
|
||||
if ((rule.ext || '').toLowerCase() !== ext) {
|
||||
if ((rule.ext || '').toLowerCase() !== cadType) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -27,8 +33,7 @@ function findDestination(filename, config) {
|
||||
}
|
||||
|
||||
function isCadFile(filename) {
|
||||
const ext = path.extname(filename).slice(1).toLowerCase();
|
||||
return ['prt', 'asm', 'dwr'].includes(ext);
|
||||
return Boolean(getCadType(filename));
|
||||
}
|
||||
|
||||
module.exports = { findDestination, isCadFile };
|
||||
|
||||
Reference in New Issue
Block a user