logicguru-engine
Version:
Advanced JSON-based rule engine with nested conditions, async evaluation, and flexible action system. Perfect for business rules, workflows, and decision automation.
17 lines (14 loc) • 556 B
JavaScript
export async function resolveFilePath(path, context) {
return path.replace(/\${([^}]+)}|\$([a-zA-Z0-9_.]+)/g, (_, nestedPath, simplePath) => {
const pathToResolve = nestedPath || simplePath;
let result = context;
for (const key of pathToResolve.split('.')) {
if (result == null) {
console.warn(`Missing context key '${key}' in path '${pathToResolve}'`);
return ''; // Return empty string for missing keys
}
result = result[key];
}
return result !== undefined ? result : '';
});
}