in mqtt-streaming/src/main/scala/org/apache/pekko/stream/connectors/mqtt/streaming/impl/RequestState.scala [640:669]
def filter(topicFilterName: String, topicName: String): Boolean = {
@tailrec
def matchStrings(tfn: String, tn: String): Boolean =
if (tfn == "/+" && tn == "/") {
true
} else if (tfn.nonEmpty && tn.nonEmpty) {
val tfnHead = tfn.charAt(0)
val tnHead = tn.charAt(0)
if (tfnHead == '/' && tnHead != '/') {
false
} else if (tfnHead == '/' && tn.length == 1) {
matchStrings(tfn, tn.tail)
} else if (tfnHead != '+' && tfnHead != '#' && tfnHead != tnHead) {
false
} else if (tfnHead == '+') {
matchStrings(tfn.tail, tn.tail.dropWhile(_ != '/'))
} else if (tfnHead == '#') {
matchStrings(tfn.tail, "")
} else {
matchStrings(tfn.tail, tn.tail)
}
} else if (tfn.isEmpty && tn.isEmpty) {
true
} else if (tfn == "/#" && tn.isEmpty) {
true
} else {
false
}
matchStrings(topicFilterName, topicName)
}