+
+
+@pytest.mark.parametrize("subject,expected", [
+ # An empty token makes a subject undeliverable: nats-server accepts the
+ # PUB without an error, but "classifier.>" never matches it and the
+ # message is dropped silently. The common case is a body ending in a
+ # full stop, which is why a posted URL followed by a sentence went
+ # unanswered with nothing in the logs.
+ ("httpswww.youtube.comwatchvco57sfct-h0.ich.will.das.",
+ "httpswww.youtube.comwatchvco57sfct-h0.ich.will.das"),
+ ("nick.dice.5.", "nick.dice.5"),
+ # a typed "..." becomes a token of its own
+ ("hallo.....welt", "hallo.welt"),
+ (".hallo", "hallo"),
+ ("nick.dice.5", "nick.dice.5"),
+ # a body of just "." leaves nothing to route on
+ (".", "_"),
+])
+def test_sanitize_subject_drops_empty_tokens(subject, expected):
+ assert _sanitize_subject(subject) == expected