Escaping characters in condition statements in IG route

Tagged: ,

This topic contains 2 replies, has 2 voices, and was last updated by  violette 8 months, 2 weeks ago.

  • Author
    Posts
  • #22636
     Sid 
    Participant

    I am trying to pass conditions for “not matches” in IG route as follows:

    “condition”: “${matches (request.uri.path, ‘^/sample/’) and not (matches (request.uri.path, ‘^/sample/pageone/.*\?.*’) )}”

    Problem is with not matches part. ^/sample/pageone/.*\?.* evaluates correctly in a regex validator but IG keeps throwing error:

    com.fasterxml.jackson.core.JsonParseException: Unrecognized character escape ‘?’ (code 63)

    Is IG handling characters differently?

    Thanks.

    #22640
     violette 
    Participant

    Hello Sid,

    JUEL does not allow to escape character in expressions. See http://juel.sourceforge.net/guide/issues.html -> JUEL doesn’t let you ‘escape’ anything except ${ and #{
    You will not be able to exclude a character but what you can do is to use the functions. For example:

    "condition": "${matches (request.uri.path, '^/sample/') and (matches (request.uri.path, '^/sample/pageone') and empty(request.uri.query))}"

    Also see: https://ea.forgerock.com/docs/ig/reference/index.html#Expressions

    Hope it helps,
    Cheers,

    #22698
     violette 
    Participant

    In fact a condition like
    "condition": "${(matches (request.uri.path, '^/sample/pageone') and empty(request.uri.query)) or matches (request.uri.path, '^/sample/(.*\\\\..*)?$')}",
    will suits better I think. But you’ll have to tweak it according to your request conditions.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

©2019 ForgeRock - we provide an identity and access platform to secure every online relationship for the enterprise market, educational sector and even entire countries. Click to view our privacy policy and terms of use.

Log in with your credentials

Forgot your details?