Skip to content

is_subject_match_wildcard

faststream.nats.schemas.js_stream.is_subject_match_wildcard #

is_subject_match_wildcard(subject, wildcard)

Check is subject suite for the wildcard pattern.

Source code in faststream/nats/schemas/js_stream.py
def is_subject_match_wildcard(subject: str, wildcard: str) -> bool:
    """Check is subject suite for the wildcard pattern."""
    if subject == wildcard:
        return True

    call = True

    for current, base in zip_longest(
        subject.split("."),
        wildcard.split("."),
        fillvalue=None,
    ):
        if base == ">":
            break

        if base != "*" and current != base:
            call = False
            break

    return call