Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex matching fails in certain cases #2

Closed
unscene opened this issue Dec 22, 2011 · 2 comments
Closed

Regex matching fails in certain cases #2

unscene opened this issue Dec 22, 2011 · 2 comments

Comments

@unscene
Copy link

unscene commented Dec 22, 2011

Found some odd behavior

/api/something/somelong-string does not match /api/something/.*

I would expect that to match. There is also a mapping for /api/.* that has a priority of 6 but the other mapping listed above has a priority of 1. So I don't think it is a precedence bug.

@unscene
Copy link
Author

unscene commented Dec 23, 2011

I wrote an acceptance test:

@Test
    public void mappingMatchedWithGenericRegexUrl() {
        String REGEX_URL_MAPPING_REQUEST =
                "{                                                  \n" +
                "   \"request\": {                                  \n" +
                "       \"method\": \"GET\",                        \n" +
                "       \"urlPattern\": \"/.*\"                     \n" +
                "   },                                              \n" +
                "   \"response\": {                                 \n" +
                "       \"body\": \"Matched!\"                      \n" +
                "   }                                               \n" +
                "}                                                    ";

            testClient.addResponse(REGEX_URL_MAPPING_REQUEST);
            WireMockResponse response = testClient.get("/api/something/this-should-match");

            assertThat(response.statusCode(), is(200));
            assertThat(response.content(), is("Matched!"));
    }

But that passes, I'll close it for now until I can successfully repro the bug. I also tried in my HTTP client to strip off the accept header but make sure the mapping required it, it didn't match but the log was different from what I was seeing.

@unscene unscene closed this as completed Dec 23, 2011
@tomakehurst
Copy link
Member

I'd suggest looking at your other mappings to make sure there isn't a higher priority one matching your request

shrutikumar15 pushed a commit to shrutikumar15/wiremock that referenced this issue Aug 13, 2023
Adjust response-definition and stub-mapping/s schemas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants