Bläddra i källkod

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

release/3.x.x
Philip Schill 3 år sedan
förälder
incheckning
b1bf7698aa
2 ändrade filer med 13 tillägg och 0 borttagningar
  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 Visa fil

@@ -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 Visa fil

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


Laddar…
Avbryt
Spara