1

I have two URL's addresses which I have filter for everyone of them:

all(uri: '/api/first/**')
{
    before =
}
all(uri: '/api/second/**')
{
    before =
}

I want to write just one filter for both. So I have tried to write a filter with regex:

all(uri: '\\/api\\/(first|second)\\/.*', regex: true)
{
    before =
}

But it doesn't work. I have tried many ways ('**' / '.*' / invert: true) But didn't succeed.

Does someone know where the mistake and what the right way to write the filter?

Thanks...

Benjy
  • 49
  • 6

1 Answers1

0

As per the documentation, uri is an ant path and does not support regular expressions. You need to rely on find:

all(regex: true, find: '/api/(first|second)/.*')
{
   before = {
       ...
   }
}
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
  • I am not sure if you really need to escape `/`, this symbol is not a special regex operator, and only must be escaped when it is used as a regex delimiter, and here, no regex delimiters are used. – Wiktor Stribiżew Mar 24 '17 at 12:53
  • I came to the filter from many other URLs. I need to come just from the both addresses – Benjy Mar 24 '17 at 13:18
  • Maybe you need to anchor the regex, like `'^/api/(first|second)/.*'`. Please update your question with more data. – Wiktor Stribiżew Mar 24 '17 at 13:32