瀏覽代碼

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

release/3.x.x
Philip Schill 3 年之前
父節點
當前提交
b1bf7698aa
共有 2 個檔案被更改,包括 13 行新增0 行删除
  1. +7
    -0
      Source/MQTTnet/Server/MqttTopicFilterComparer.cs
  2. +6
    -0
      Tests/MQTTnet.Core.Tests/TopicFilterComparer_Tests.cs

+ 7
- 0
Source/MQTTnet/Server/MqttTopicFilterComparer.cs 查看文件

@@ -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++;


+ 6
- 0
Tests/MQTTnet.Core.Tests/TopicFilterComparer_Tests.cs 查看文件

@@ -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()
{


Loading…
取消
儲存