Fix issue with spaces after comma and or filters

Combined filters separated with comma and a space resulted in an error. 
Example: 
Title==D, (Title|LikeCount)==3
Caused the error: "(Title not found"

Extended regex to allow whitespaces after the comma as documented.
This commit is contained in:
Alexander Weggerle 2020-07-04 21:16:54 +02:00
parent d86e35f77c
commit 6684524fcd
2 changed files with 18 additions and 1 deletions

View File

@ -13,7 +13,7 @@ namespace Sieve.Models
where TFilterTerm : IFilterTerm, new()
where TSortTerm : ISortTerm, new()
{
private const string EscapedCommaPattern = @"(?<!($|[^\\])(\\\\)*?\\),";
private const string EscapedCommaPattern = @"(?<!($|[^\\])(\\\\)*?\\),\s*";
[DataMember]
public string Filters { get; set; }

View File

@ -352,6 +352,23 @@ namespace SieveUnitTests
Assert.AreEqual(3, entry.Id);
}
[TestMethod]
public void CombinedAndOrWithSpaceFilteringWorks()
{
var model = new SieveModel()
{
Filters = "Title==D, (Title|LikeCount)==3",
};
var result = _processor.Apply(model, _posts);
var entry = result.FirstOrDefault();
var resultCount = result.Count();
Assert.IsNotNull(entry);
Assert.AreEqual(1, resultCount);
Assert.AreEqual(3, entry.Id);
}
[TestMethod]
public void OrValueFilteringWorks()
{