Reply To: More prety way to ignore Image and CSS on Join

Splash Forums Rewrite Users More prety way to ignore Image and CSS on Join Reply To: More prety way to ignore Image and CSS on Join

#24791

I typically create a private method in the configuration provider like this:

private Condition isNoStaticResource() {
  return Not.any( Path.matches("{*}.jpg").or( Path.matches("{*}.gif") ) );
}

Then I can use this method to add the condition to multiple rules like this:

.addRule(Join.path(“/{page}”).to(“/{page}.jsf”) )
.when(isNoStaticResource()))
.where(“page”).matches(“[a-zA-Z/]+”)

You could also create a custom condition which is very very simple. Something like this:

public class NoStaticResource implements Condition {

  public boolean evaluate(Rewrite event, EvaluationContext context) {

    Condition wrapped = Not.any( Path.matches("{*}.jpg").or( Path.matches("{*}.gif") ) );

    return wrapped.evaluate(event, context);

  } 

}

Then you can use your custom condition like this:

.addRule(Join.path(“/{page}”).to(“/{page}.jsf”) )
.when( new NoStaticResource() )
.where(“page”).matches(“[a-zA-Z/]+”)