The topic filter comparer now checks for e.g. "foo/" matching "foo/#".

This commit is contained in:
Philip Schill
2021-01-29 17:37:47 +01:00
parent df45540d6b
commit b1bf7698aa
2 changed files with 13 additions and 0 deletions
@@ -31,6 +31,13 @@ namespace MQTTnet.Server
{
return true;
}
// Check for e.g. foo/ matching foo/#
if (sPos == sLen - 2
&& filter[sPos] == LevelSeparator
&& filter[sPos + 1] == MultiLevelWildcard)
{
return true;
}
}
sPos++;
@@ -54,6 +54,12 @@ namespace MQTTnet.Tests
CompareAndAssert("A/B/C/D", "A/C/#", false);
}
[TestMethod]
public void TopicFilterComparer_EndMultipleLevelsWildcardMatchEmptyLevel()
{
CompareAndAssert("A/", "A/#", true);
}
[TestMethod]
public void TopicFilterComparer_AllLevelsWildcardMatch()
{