Yes! Absolutely.
The simplest way to do this is probably use a parameter with a regex .matches()
constraint:
cb.addRule(
Join.path('/{path}').to("/test.xhtml"))
.where("path")
.matches("(?i)test"); // <-- your path regex pattern goes here
You could also use the Resource
or Filesystem
condition with a custom transform to make this a more global rule:
public class Lowercase implements Transposition<String>
{
@Override
public String transpose(Rewrite event, EvaluationContext context, String value)
{
return value.toLowerCase();
}
}
Then...
.addRule(Join.path("/{path}").to("/{path}.xhtml"))
.when(Resource.exists("{path}.xhtml"))
.where("path")
.matches("[a-zA-Z]+")
.transposedBy(new Lowercase())
This of course assumes that your xhtml files all use a lowercase naming scheme.
You could create your own custom .when()
conditions to locate the most likely matches, then substitute the 'found / correct' value of {path}
in the transposition, if you wanted to go even farther.