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

QueryMatcher Case Sensitiviy #134

Open
archerbird opened this issue Dec 13, 2023 · 3 comments
Open

QueryMatcher Case Sensitiviy #134

archerbird opened this issue Dec 13, 2023 · 3 comments

Comments

@archerbird
Copy link

Would it be possible to add an option to make the QueryMatcher check for parameter keys in a case insensitive?

@Iceeman76
Copy link

I agree! not only for parameters but also for urls and json-strings would be nice

@pbolduc
Copy link

pbolduc commented Feb 17, 2024

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; }
}

@pbolduc
Copy link

pbolduc commented Feb 18, 2024

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.

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

3 participants