shamblett / mqtt5_client

A server and browser based MQTT 5 client for dart
Other
49 stars 25 forks source link

MqttSubscriptionTopic().matches function throws exception upon different lengths of topics #77

Closed ashu-pietech closed 6 months ago

ashu-pietech commented 8 months ago

I found that MqttSubscriptionTopic().matches function is throwing error upon comparing two different topics. But the case is that base topic's length must be greater than the comparing topic's length then it throws this error:

`[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: RangeError (index): Invalid value: Not in inclusive range 0..3: 4

0 List.[] (dart:core-patch/growable_array.dart:264:36)

1 MqttSubscriptionTopic.matches (package:mqtt5_client/src/mqtt_subscription_topic.dart:93:56)`

Steps to reproduce:

  1. The raw topic passed inside the MqttSubscriptionTopic() must be of greater length if separated by "/" than the topic passed inside MqttPublicationTopic()
  2. compare both using the MqttSubscriptionTopic("passed raw topic").matches function

I've fixed the above issue and I'll create a PR

ashu-pietech commented 8 months ago

created PR for the same issue #78

shamblett commented 6 months ago

Merged, package re published at version 4.2.0