Skip to content

Commit

Permalink
Merge pull request #19 from Necromant1k/fixes/namespaces
Browse files Browse the repository at this point in the history
fix(generator): Respect namespace, prevent name collision
  • Loading branch information
omar-dulaimi authored May 19, 2023
2 parents 0769f66 + 8540088 commit 0fac234
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ export function generateMiddlewareFromRuleTree<TContext extends Record<string, u
//@ts-ignore
rule = ruleTree?.[type]?.[opName] || options.fallbackRule;
} else {
for (const key of keys) {
//@ts-ignore
const namespace = ruleTree[key];
if (namespace?.[type]?.[opName]) {
rule = namespace?.[type]?.[opName] || options.fallbackRule;
break;
}
const namespace = opWithPath[0];

const tree = (ruleTree as Record<string, any>)[namespace];
if (tree?.[type]?.[opName]) {
rule = tree?.[type]?.[opName] || options.fallbackRule;
}
}

Expand Down

0 comments on commit 0fac234

Please sign in to comment.