Skip to content

Commit

Permalink
fix: 'topic/subtopic' matches 'topic/subtopic/#'
Browse files Browse the repository at this point in the history
  • Loading branch information
steersbob authored and empicano committed Aug 3, 2023
1 parent 3ad32f7 commit c2cc37f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aiomqtt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def matches(self, wildcard: WildcardLike) -> bool:

def recurse(x: list[str], y: list[str]) -> bool:
if not x:
if not y:
if not y or y[0] == "#":
return True
return False
if not y:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,14 @@ async def test_topic_matches() -> None:
assert topic.matches("+/+/+")
assert topic.matches("+/#")
assert topic.matches("#")
assert topic.matches("a/b/c/#")
assert topic.matches("$share/group/a/b/c")
assert topic.matches("$share/group/a/b/+")
assert not topic.matches("abc")
assert not topic.matches("a/b")
assert not topic.matches("a/b/c/d")
assert not topic.matches("a/b/z")
assert not topic.matches("a/b/c/+")
assert not topic.matches("$share/a/b/c")
assert not topic.matches("$test/group/a/b/c")

Expand Down

0 comments on commit c2cc37f

Please # to comment.