I'm not sure if its a bug or limitation of the lib. Maybe a future enhancement.
I have a request with a query param who value contains a white space.
I followed example bellow in README but it does not work:
- The following will match either of these:
- /with/parameters?search=search+terms&filter=month
- /with/parameters?filter=month&search=search+terms
- request:
url: ^/with/parameters$
query:
search: search terms
filter: month
My query param was
- request:
method: GET
url: ^/test$
query:
term: "boo and foo"
And in jUnit test
String request = "http://localhost:8882/test?term=boo and foo"
which is encoded and returns not found
404 [/test?term=boo+and+foo] Not Found
So i changed de yml query param to "boo+and+foo" in order to match, but i'm still getting 404.
[35mLoaded: [GET] ^/test$?term=boo+and+foo]
404 [/test?term=boo+and+foo] Not Found
The solution i found was encoding the '+' char in yml file:
query:
term: "boo%2Band%2Bfoo"
And change my test to:
String request = "http://localhost:8882/test?term=boo+and+foo"
in order to encode "+" char to "%2B" and them match.
I think that is caused by regex processing, so i tried another test, escaping '+' symbol in yml file
query:
term: "boo\\+and\\+foo"
In this way, i can write request strings in java without any encoding troubles as folowing:
String request = "http://localhost:8882/test?term=boo and foo"
[35mLoaded: [GET] ^/test$?term=boo\+and\+foo]
200 [/test?term=boo+and+foo] OK
As i said, i'm not sure if it can be considered as a bug or lib's limitation. Maybe a future enhancement, or just an update in docs about this specific case. Another chars encoding does not have this problem.
I hope that it helps to improve this awesome lib. Thanks!