Skip to content

Commit

Permalink
fixup! feat(binding_mqtt): support MQTT URI scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Jan 12, 2024
1 parent 514b21a commit 050525b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/src/binding_mqtt/mqtt_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,17 @@ extension MqttFormExtension on AugmentedForm {

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

if (topic == null) {
throw MqttBindingException("MQTT topic was not defined on form.");
if (topic != null) {
return topic;
}

return topic;
return Uri.decodeComponent(href.query.replaceAll("&", "/"));
}

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

0 comments on commit 050525b

Please sign in to comment.