Skip to content

Commit f57d066

Browse files
committed
fixup! feat(binding_mqtt): support MQTT URI scheme
1 parent 35bc521 commit f57d066

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
@@ -107,15 +107,17 @@ extension MqttFormExtension on AugmentedForm {
107107

108108
/// Gets the MQTT topic for subscribing from this [Form].
109109
///
110-
/// Throws an [Exception] if no topic could be retrieved.
110+
/// If present, this getter uses the dedicated vocabulary term `filter`.
111+
/// Otherwise, the URI query from the `href` field is being used as a
112+
/// fallback.
111113
String get topicFilter {
112114
final topic = _obtainVocabularyTerm<String>("filter");
113115

114-
if (topic == null) {
115-
throw MqttBindingException("MQTT topic was not defined on form.");
116+
if (topic != null) {
117+
return topic;
116118
}
117119

118-
return topic;
120+
return Uri.decodeComponent(href.query.replaceAll("&", "/"));
119121
}
120122

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

0 commit comments

Comments
 (0)