Alan Wong
08/02/2024, 9:10 AM^https:\/\/some.corp.com\/path$|^https:\/\/some.corp.com\/otherpath$
so if I call
Matching(R"(^https:\/\/some.corp.com\/path$|^https:\/\/some.corp.com\/otherpath$)", var.toStdString())
the created json shows:
"matchingRules": {
"body": {
"$.type": {
"combine": "AND",
"matchers": [
{
"match": "regex",
"regex": "^https:\\/\\/some.corp.com\\/path$|^https:\\/\\/some.corp.com\\/otherpath$"
}
]
}
},
"header": {}
},
Is this correct?
I would expect the regex pattern to show
"regex": "^https:\/\/some.corp.com\/path$|^https:\/\/some.corp.com\/otherpath$"
Alan Wong
08/02/2024, 10:17 AM"regex": "^<https://some.corp.com/path$%7C^https://some.corp.com/otherpath$>"
if the consumer was Java, Go, Rust, C++?Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Joshua Ellis
08/04/2024, 11:38 PM\n
in a JSON string translates to a newline and not the literal \
and n
characters. As a result, \\/
does correspond to that value of \
and /
.
You can check the actual value (once deserialised) as follows:
# Having copied the JSON string, including the surrounding `"`
$ pbpaste | jq -r
^https:\/\/some.corp.com\/path$|^https:\/\/some.corp.com\/otherpath$
Note that pbpaste
is a macOS tool to output what is in the clipboard. There will be other tools available on other platforms, and I highly recommend using such a tool again to avoid any risk of the shell interfering with backslashes in the string 🙂Alan Wong
08/05/2024, 6:08 AM"regex": "^<https://some.corp.com/path$%7C^https://some.corp.com/otherpath$>"
should be fine.Joshua Ellis
08/05/2024, 6:10 AM%7C
in the middle whether it is intentional or not.Alan Wong
08/05/2024, 6:14 AM"regex": "^<https://some.corp.com/path$%7C^https://some.corp.com/otherpath$>"
Alan Wong
08/05/2024, 6:15 AM|
into %7C
against my wishes, please ignore itJoshua Ellis
08/05/2024, 6:16 AMAlan Wong
08/05/2024, 6:18 AM