Configuring standalone Wiremock via json in /mappings, ran into the following behavior:
mapping: "urlPattern": "/your/url"
test: /your/url
result: Match! (as expected)
mapping: "urlPattern": "/your/([a-z]*)"
test: /your/url"
result: Match! (as expected)
mapping: "urlPattern": "/your/([a-z]*)?and=query"
test: /your/url?and=query"
result:
No Match... note this is the exact example used in the "Regex matching on path and query" section here:
http://wiremock.org/docs/request-matching/It seems that the addition of query parameters changes the way regex is applied to the PATH portion of the url.
To get the documentation example to work, you need to do the following:
mapping: "urlPattern": "\\/your\\/([a-z]*)\?and=query"
test: /your/url?and=query
result: Match! (note the double backslash before every forward slash and the question mark)
It seems like the best approach would be to use urlPathPattern in addition to queryParameters, rather than regex on the combined URL. However, the documentation seems to be incorrect ("Regex matching on path and query" here:
http://wiremock.org/docs/request-matching/), unless I am missing something.