More granular on path search

This commit is contained in:
Matt Nadareski
2021-03-22 01:18:49 -07:00
parent e4278c55b7
commit 129ac1bb78

View File

@@ -12,9 +12,15 @@ namespace BurnOutSharp.Matching
/// </summary>
public string Needle { get; set; }
public PathMatch(string needle)
/// <summary>
/// Match that values end with the needle and not just contains
/// </summary>
public bool UseEndsWith { get; set; }
public PathMatch(string needle, bool useEndsWith = false)
{
Needle = needle;
UseEndsWith = useEndsWith;
}
#region Matching
@@ -31,7 +37,9 @@ namespace BurnOutSharp.Matching
foreach (string stackItem in stack)
{
if (stackItem.Contains(Needle))
if (UseEndsWith && stackItem.EndsWith(Needle))
return (true, stackItem);
else if (!UseEndsWith && stackItem.Contains(Needle))
return (true, stackItem);
}