mirror of
https://github.com/Biarity/Sieve.git
synced 2024-11-23 22:12:48 +01:00
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:
parent
d86e35f77c
commit
6684524fcd
@ -13,7 +13,7 @@ namespace Sieve.Models
|
|||||||
where TFilterTerm : IFilterTerm, new()
|
where TFilterTerm : IFilterTerm, new()
|
||||||
where TSortTerm : ISortTerm, new()
|
where TSortTerm : ISortTerm, new()
|
||||||
{
|
{
|
||||||
private const string EscapedCommaPattern = @"(?<!($|[^\\])(\\\\)*?\\),";
|
private const string EscapedCommaPattern = @"(?<!($|[^\\])(\\\\)*?\\),\s*";
|
||||||
|
|
||||||
[DataMember]
|
[DataMember]
|
||||||
public string Filters { get; set; }
|
public string Filters { get; set; }
|
||||||
|
@ -352,6 +352,23 @@ namespace SieveUnitTests
|
|||||||
Assert.AreEqual(3, entry.Id);
|
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]
|
[TestMethod]
|
||||||
public void OrValueFilteringWorks()
|
public void OrValueFilteringWorks()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user