mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-18 02:13:00 +08:00
Fix unit tests for topic templates (#1976)
This commit is contained in:
@@ -152,17 +152,28 @@ namespace MQTTnet.Extensions.TopicTemplate
|
||||
}
|
||||
}
|
||||
|
||||
return a.Substring(0, maxIndex);
|
||||
return a.Substring(0, maxIndex+1);
|
||||
}
|
||||
|
||||
foreach (var topic in from template in templates select template.Template)
|
||||
foreach (string topic in from template in templates select template.Template)
|
||||
{
|
||||
root = root == null ? topic : CommonPrefix(root, topic);
|
||||
}
|
||||
|
||||
root = root ?? "";
|
||||
if (string.IsNullOrEmpty(root))
|
||||
return new MqttTopicTemplate(MqttTopicFilterComparer.MultiLevelWildcard.ToString());
|
||||
|
||||
return new MqttTopicTemplate(root.Substring(0, root.LastIndexOf('/')));
|
||||
if (root.Contains(MqttTopicFilterComparer.LevelSeparator) &&
|
||||
!root.EndsWith(MqttTopicFilterComparer.LevelSeparator.ToString()) &&
|
||||
!root.EndsWith("}"))
|
||||
{
|
||||
root = root.Substring(0, root.LastIndexOf(MqttTopicFilterComparer.LevelSeparator)+1);
|
||||
}
|
||||
|
||||
if (root.EndsWith(MqttTopicFilterComparer.LevelSeparator.ToString()))
|
||||
root += MqttTopicFilterComparer.SingleLevelWildcard;
|
||||
|
||||
return new MqttTopicTemplate(root);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
|
||||
Reference in New Issue
Block a user