fix: corregge drag & drop e riconoscimento estensioni CAD versionate

This commit is contained in:
2026-03-05 16:46:03 +01:00
parent 8edc2673b3
commit 5b65a9bd04
3 changed files with 21 additions and 8 deletions

View File

@@ -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 };