Commit iniziale
This commit is contained in:
29
services/router.js
Normal file
29
services/router.js
Normal file
@@ -0,0 +1,29 @@
|
||||
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 };
|
||||
Reference in New Issue
Block a user