Skip to content

Commit 9c64670

Browse files
committed
fixup! feat(binding_mqtt): support MQTT URI scheme
1 parent 1d9ece4 commit 9c64670

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/src/binding_mqtt/mqtt_extensions.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,17 @@ extension MqttFormExtension on Form {
111111

112112
/// Gets the MQTT topic for subscribing from this [Form].
113113
///
114-
/// Throws an [Exception] if no topic could be retrieved.
114+
/// If present, this getter uses the dedicated vocabulary term `filter`.
115+
/// Otherwise, the URI query from the `href` field is being used as a
116+
/// fallback.
115117
String get topicFilter {
116118
final topic = _obtainVocabularyTerm<String>('filter');
117119

118-
if (topic == null) {
119-
throw MqttBindingException('MQTT topic was not defined on form.');
120+
if (topic != null) {
121+
return topic;
120122
}
121123

122-
return topic;
124+
return Uri.decodeComponent(href.query.replaceAll('&', '/'));
123125
}
124126

125127
/// Gets the MQTT `retain` value from this [Form] if present.

0 commit comments

Comments
 (0)