fix: getRoute last

This commit is contained in:
Jean-Baptiste Pasquier 2021-05-20 16:50:56 +02:00
parent d397040d59
commit 8f5aed11e0

View File

@ -12,11 +12,16 @@
let routes = new Set(); let routes = new Set();
const getRoute = (type, returnFirst = false) => { const getRoute = (type, returnFirst = false) => {
let availables = components.filter(c=>c.type==type||c.uniq==type); let availables = components.filter(c=>c.type==type||c.uniq==type);
availables.map(c => {
if(c.extensions) {
c.extensions.forEach(e => availables.push(e.type));
}
});
if(availables.length > 1) { if(availables.length > 1) {
if(returnFirst) { if(returnFirst) {
return availables[0].route; return availables[0].route;
} else { } else {
return availables[availables.length-1] .route; return availables[availables.length-1].route;
} }
} else if(availables.length < 1) { } else if(availables.length < 1) {
console.error(`No component found for route ${type}`); console.error(`No component found for route ${type}`);