diff --git a/BurnOutSharp/Matching/Matcher.cs b/BurnOutSharp/Matching/Matcher.cs index 91186d3e..c3503ba6 100644 --- a/BurnOutSharp/Matching/Matcher.cs +++ b/BurnOutSharp/Matching/Matcher.cs @@ -100,7 +100,7 @@ namespace BurnOutSharp.Matching /// Determine whether all content matches pass /// /// Byte array representing the file contents - /// Tuole of passing status and matching positions + /// Tuple of passing status and matching positions public (bool, List) MatchesAll(byte[] fileContent) { // If no content matches are defined, we fail out @@ -127,7 +127,7 @@ namespace BurnOutSharp.Matching /// Determine whether all content matches pass /// /// List of strings to try to match - /// Tuole of passing status and matching values + /// Tuple of passing status and matching values public (bool, List) MatchesAll(List stack) { // If no path matches are defined, we fail out @@ -154,7 +154,7 @@ namespace BurnOutSharp.Matching /// Determine whether any content matches pass /// /// List of strings to try to match - /// Tuole of passing status and matching values + /// Tuple of passing status and matching values public (bool, string) MatchesAny(List stack) { // If no path matches are defined, we fail out diff --git a/BurnOutSharp/Matching/PathMatch.cs b/BurnOutSharp/Matching/PathMatch.cs index ba9b702c..b1a6c460 100644 --- a/BurnOutSharp/Matching/PathMatch.cs +++ b/BurnOutSharp/Matching/PathMatch.cs @@ -12,14 +12,20 @@ namespace BurnOutSharp.Matching /// public string Needle { get; set; } + /// + /// Match exact casing instead of invariant + /// + public bool MatchExact { get; set; } + /// /// Match that values end with the needle and not just contains /// public bool UseEndsWith { get; set; } - public PathMatch(string needle, bool useEndsWith = false) + public PathMatch(string needle, bool matchExact = false, bool useEndsWith = false) { Needle = needle; + MatchExact = matchExact; UseEndsWith = useEndsWith; } @@ -35,11 +41,17 @@ namespace BurnOutSharp.Matching if (stack == null || stack.Count == 0 || Needle == null || Needle.Length == 0) return (false, null); + // Preprocess the needle, if necessary + string procNeedle = MatchExact ? Needle : Needle.ToLowerInvariant(); + foreach (string stackItem in stack) { - if (UseEndsWith && stackItem.EndsWith(Needle)) + // Preprocess the stack item, ir necessary + string procStackItem = MatchExact ? stackItem : stackItem.ToLowerInvariant(); + + if (UseEndsWith && procStackItem.EndsWith(procNeedle)) return (true, stackItem); - else if (!UseEndsWith && stackItem.Contains(Needle)) + else if (!UseEndsWith && procStackItem.Contains(procNeedle)) return (true, stackItem); }