MatchesPath Vs Matches

I noticed some behavior related to pattern matching on Apigee Edge that requires some looking into. Consider the following conditional flows in the Proxy endpoint (basepath: /examples) of a proxy as an example. The only difference is the operator being use “MatchesPath” in Flow A vs “Matches” in Flow B.

A.

JS-ExtractVariables

(proxy.pathsuffix MatchesPath “/”) and (request.verb = “GET”)

B.

JS-ExtractVariables

(proxy.pathsuffix Matches “/”) and (request.verb = “GET”)

I ran the following tests on both flows:



Flow



URI



Trace expression



Trace express result



proxy.pathsuffix



A



https://api-sandbox.apigee.appliedcloudservices.com/examples/




(proxy.pathsuffix matches / and (request.verb equals “GET”))







false



/



A



https://api-sandbox.apigee.appliedcloudservices.com/examples



(proxy.pathsuffix matches / and (request.verb equals “GET”))



true







B



https://api-sandbox.apigee.appliedcloudservices.com/examples



(proxy.pathsuffix matches / and (request.verb equals “GET”))



false







B



https://api-sandbox.apigee.appliedcloudservices.com/examples/




(proxy.pathsuffix matches / and (request.verb equals “GET”))







true



/

Notice that the expression executed/displayed is the same, however, results are different. The operator “Matches” works as expected whereas “MatchesPath” returns true when proxy.pathsuffix is empty and return true when value (“/”) should match. Is there an explanation for this?

I believe the MatchesPath operator is intended to help with path fragment matching and match against one or multiple paths by using single * or double **

https://docs.apigee.com/api-platform/fundamentals/flow-variables-and-conditions#operators

Thanks @dknezic ! I understand that documented description of it. My question was

  1. Why the expression being evaluated/displayed in trace for MatchesPath and Matches the same?

  2. Given that it’s same then why are the results different?

  1. You’re right, I can reproduce this discrepancy in the trace in both Apigee Edge and Apigee X. I believe this is just a cosmetic issue that it’s showing the wrong thing in the case of MatchesPath, will raise this issue.

  2. It’s not actually the same and I believe you should only use MatchesPath when you’re trying to use wildcard matching.

1 Like