LukeMathWalker / wiremock-rs

HTTP mocking to test Rust applications.
Apache License 2.0
624 stars 72 forks source link

Panic if `path` contains `?` #104

Closed MarcoIeni closed 1 year ago

MarcoIeni commented 2 years ago

I noticed a lot of people (including me) when using wiremock often forget about query_param and put ? in the path, doing stuff like:

    Mock::given(method("GET"))
        .and(path("abcd/?letter=e"));

instead of

    Mock::given(method("GET"))
        .and(path("abcd/"))
        .and(query_param("letter","e"));

Can we validate the path with this approach?

LukeMathWalker commented 2 years ago

I'm inclined to merge this, but I am not 100% that there is no legit usage of ? in a path outside of the context of query parameters. I'd have to check the spec.

LukeMathWalker commented 1 year ago

We should probably do something similar for the path matcher - panic if they included the URL base in there.

MarcoIeni commented 1 year ago

We should probably do something similar for the path matcher - panic if they included the URL base in there.

Can you open an issue where you write a piece of code as an example and assign the issue to me? I would be happy to open a PR 😄

LukeMathWalker commented 1 year ago

106 - here you go @MarcoIeni ❤️