Files
cad-data-router/services/router.js
2026-03-05 14:45:06 +01:00

30 lines
658 B
JavaScript

const path = require('path');
function findDestination(filename, config) {
const ext = path.extname(filename).slice(1).toLowerCase();
for (const rule of config.rules || []) {
if ((rule.ext || '').toLowerCase() !== ext) {
continue;
}
if (!rule.pattern) {
return rule.destination;
}
const regex = new RegExp(rule.pattern);
if (regex.test(path.basename(filename))) {
return rule.destination;
}
}
return null;
}
function isCadFile(filename) {
const ext = path.extname(filename).slice(1).toLowerCase();
return ['prt', 'asm', 'drw'].includes(ext);
}
module.exports = { findDestination, isCadFile };