mockhttp
mockhttp copied to clipboard
QueryMatcher Case Sensitiviy
Would it be possible to add an option to make the QueryMatcher check for parameter keys in a case insensitive?
I agree! not only for parameters but also for urls and json-strings would be nice
I wonder if a QueryStringMatcherOptions class was added. Something along the lines the following. The WithQueryString extension methods could take an optional QueryStringMatcherOptions and construct a new instance if null. the new instance defaults to Ordinal Case Sensitive comparison.
Is this something you would accept in a PR?
/// <summary>
/// Provides options on how to match query strings.
/// </summary>
public sealed class QueryStringMatcherOptions
{
/// <summary>
/// Constructs a new instance of QueryStringMatcherOptions using the default ordinal comparison on keys and values.
/// </summary>
public QueryStringMatcherOptions() : this(StringComparer.Ordinal, StringComparer.Ordinal)
{
}
/// <summary>
/// Constructs a new instance of QueryStringMatcherOptions using the default ordinal comparison on keys and values.
/// </summary>
public QueryStringMatcherOptions(IEqualityComparer<string>? key = null, IEqualityComparer<string>? value = null)
{
KeyComparer = key ?? StringComparer.Ordinal;
ValueComparer = value ?? StringComparer.Ordinal;
}
/// <summary>
/// The comparer to use for keys
/// </summary>
public IEqualityComparer<string> KeyComparer { get; }
/// <summary>
/// The comparer to use for values
/// </summary>
public IEqualityComparer<string> ValueComparer { get; }
}
Would it be possible to add an option to make the QueryMatcher check for parameter keys in a case insensitive?
Could you explain your use case on the problem you are trying to solve by performing a case insensitive comparison? Knowing the problem you are trying to solve will ensure any features developed will match the problem you are trying to solve.