The duplicate logic can be reduced by refactoring the logic:

1. if there are no rewrite rules, cast to an empty array and issue warning.
2. Proceed with the rendering, as before the PR.