Condition matching variable

I am trying to check if the "proxy.pathsuffix" has part of the value from the kvm (assume the variable "kvm.value").

let's assume proxy.pathsuffix as : "/name1/name2/name3/" and kvm has the value "name2". I want to check if "name2" is in the pathsuffix.

I used the command bellow but it doesn't work, please can you help me?

<Condition>proxy.pathsuffix Matches "**/kvm.value/**"</Condition>
0 3 1,103
3 REPLIES 3

Hi Luis, the "matches" operator only allows using wildcards in the path expression, but not variables.

You could use a Javascript policy to set a boolean variable (eg: pathHasValue) to true if proxy.pathsuffix contains the string represented by kvm.value, and then change your condition to

pathHasValue = "true"

I was trying to avoid using JS.
Thank you for the reply.

sidd-harth
Participant V

As said by @deboraelkin, use JS after KVM policy,

var kvmValue = context.getVariable("some-value"); //KVM assignTo value
var path = context.getVariable("proxy.pathsuffix");
var pathHasValue = kvmValue.includes(path);
  
  
context.setVariable("kvmValue", kvmValue);
context.setVariable("pathValue", path);
context.setVariable("pathHasValue", pathHasValue);
<Step>
    <Name>Policy</Name>
    <Condition>(pathHasValue = "true")</Condition> <!-- true | false -->
</Step>