Can ExactMatcher (on Request) include IgnoreCase? #445

Closed
opened 2025-12-29 08:28:17 +01:00 by adam · 12 comments
Owner

Originally created by @mattisking on GitHub (Sep 15, 2022).

I've got an API I've mocked, a nice and simple one, which is nothing but a kind of lookup service so just simple restful gets. An example might look like:
[HttpGet]
/lookup/{id}

The Request part of my mapping:
"Request": {
"Path": {
"Matchers": [
{
"Name": "ExactMatcher",
"Pattern": "/lookup/12345"
}
]
},

This gives me the ability to set a bunch of specific responses for various values. In order to have a "catchall", I've also got this other mapping:
"Request": {
"Path": {
"Matchers": [
{
"Name": "WildcardMatcher",
"Pattern": "/lookup/*",
"IgnoreCase": true
}
]
},
This serves me well as I can define a bunch of custom cases, but also have a catch all for other values where I want to return a default response.

The problem is that the ExactMatcher doesn't appear to support IgnoreCase which to a degree I understand... it's an exact match, but in truth, casing in a URL's route is generally going to work fine regardless of case:
/lookup/12345
and
/Lookup/1235

are going to work the same for the vast majority of API calls and I'd argue remain an "exact match" in most cases (most cases, so the IgnoreCase option remains a good choice).

Originally created by @mattisking on GitHub (Sep 15, 2022). I've got an API I've mocked, a nice and simple one, which is nothing but a kind of lookup service so just simple restful gets. An example might look like: [HttpGet] /lookup/{id} The Request part of my mapping: "Request": { "Path": { "Matchers": [ { "Name": "ExactMatcher", "Pattern": "/lookup/12345" } ] }, This gives me the ability to set a bunch of specific responses for various values. In order to have a "catchall", I've also got this other mapping: "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/lookup/*", "IgnoreCase": true } ] }, This serves me well as I can define a bunch of custom cases, but also have a catch all for other values where I want to return a default response. The problem is that the ExactMatcher doesn't appear to support IgnoreCase which to a degree I understand... it's an exact match, but in truth, casing in a URL's route is generally going to work fine regardless of case: /lookup/12345 and /Lookup/1235 are going to work the same for the vast majority of API calls and I'd argue remain an "exact match" in most cases (most cases, so the IgnoreCase option remains a good choice).
adam added the question label 2025-12-29 08:28:17 +01:00
adam closed this issue 2025-12-29 08:28:17 +01:00
Author
Owner

@StefH commented on GitHub (Sep 15, 2022):

Can't you just use a WildcardMatcher with /lookup/12345 and ignorecase = true?

@StefH commented on GitHub (Sep 15, 2022): Can't you just use a `WildcardMatcher` with `/lookup/12345` and ignorecase = true?
Author
Owner

@mattisking commented on GitHub (Sep 15, 2022):

If I do that, then my WildCard one I setup now catches everything if the path case is different.

Example:
ExactMatcher:
/lookup/12345
return: { "id": 1 }

WildcardMatcher:
/lookup/*
IgnoreCase: true
return: { "id": 2 }

Test cases:
/lookup/12345
will return { "id": 1 }

/Lookup/12345
will return { "id": 2 }, but I want { "id": 1 }

@mattisking commented on GitHub (Sep 15, 2022): If I do that, then my WildCard one I setup now catches everything if the path case is different. Example: ExactMatcher: /lookup/12345 return: { "id": 1 } WildcardMatcher: /lookup/* IgnoreCase: true return: { "id": 2 } Test cases: /lookup/12345 will return { "id": 1 } /Lookup/12345 will return { "id": 2 }, but I want { "id": 1 }
Author
Owner

@StefH commented on GitHub (Sep 15, 2022):

Ah.

In that case I think regexmatcher will be the best choice for you:
https://github.com/WireMock-Net/WireMock.Net/wiki/Request-Matching#regular-expression-matching-regexmatcher

Which is powerfull because it's regex, and also supports ignore case.

@StefH commented on GitHub (Sep 15, 2022): Ah. In that case I think regexmatcher will be the best choice for you: https://github.com/WireMock-Net/WireMock.Net/wiki/Request-Matching#regular-expression-matching-regexmatcher Which is powerfull because it's regex, and also supports ignore case.
Author
Owner

@mattisking commented on GitHub (Sep 15, 2022):

It’s not ideal for my use case but I can make it work in conjunction with Priority:

“Priority”: 1
“Request": {
"Path": {
"Matchers": [
{
"Name": "RegexMatcher",
"Pattern": "/lookup/12345$",
“IgnoreCase”: true
}
]
},

“Priority”: 2,
"Request": {
"Path": {
"Matchers": [
{
"Name": "WildcardMatcher",
"Pattern": "/lookup/*",
"IgnoreCase": true
}
]
},

@mattisking commented on GitHub (Sep 15, 2022): It’s not ideal for my use case but I can make it work in conjunction with Priority: “Priority”: 1 “Request": { "Path": { "Matchers": [ { "Name": "RegexMatcher", "Pattern": "/lookup/12345$", “IgnoreCase”: true } ] }, “Priority”: 2, "Request": { "Path": { "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "/lookup/*", "IgnoreCase": true } ] },
Author
Owner

@StefH commented on GitHub (Sep 17, 2022):

@mattisking
I did update the ExactMather to support IgnoreCase.

please test preview version 1.5.6-ci-16453

@StefH commented on GitHub (Sep 17, 2022): @mattisking I did update the ExactMather to support IgnoreCase. please test preview version `1.5.6-ci-16453`
Author
Owner

@StefH commented on GitHub (Sep 21, 2022):

@mattisking Can you test this?

@StefH commented on GitHub (Sep 21, 2022): @mattisking Can you test this?
Author
Owner

@mattisking commented on GitHub (Sep 21, 2022):

I will test it today. Sorry, Business travel.

@mattisking commented on GitHub (Sep 21, 2022): I will test it today. Sorry, Business travel.
Author
Owner

@StefH commented on GitHub (Sep 26, 2022):

@mattisking
Did you time to test?

@StefH commented on GitHub (Sep 26, 2022): @mattisking Did you time to test?
Author
Owner

@StefH commented on GitHub (Sep 29, 2022):

@mattisking ; can you please test this?

@StefH commented on GitHub (Sep 29, 2022): @mattisking ; can you please test this?
Author
Owner

@StefH commented on GitHub (Oct 3, 2022):

@mattisking , if you have time, can you please test this?

(Then I can merge this to master)

@StefH commented on GitHub (Oct 3, 2022): @mattisking , if you have time, can you please test this? (Then I can merge this to master)
Author
Owner

@StefH commented on GitHub (Oct 12, 2022):

@mattisking
Did you have time yet to verify?

@StefH commented on GitHub (Oct 12, 2022): @mattisking Did you have time yet to verify?
Author
Owner

@StefH commented on GitHub (Oct 15, 2022):

https://github.com/WireMock-Net/WireMock.Net/pull/817

PR will be merged. A new NuGet will be released this weekend,

@StefH commented on GitHub (Oct 15, 2022): https://github.com/WireMock-Net/WireMock.Net/pull/817 PR will be merged. A new NuGet will be released this weekend,
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net#445