File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -87,15 +87,22 @@ extension MqttFormExtension on AugmentedForm {
8787
8888 /// Gets the MQTT topic for publishing from this [Form] .
8989 ///
90- /// Throws an [Exception] if no topic could be retrieved.
90+ /// If present, this getter uses the dedicated vocabulary term `topic` .
91+ /// Otherwise, the URI path from the `href` field is being used as a fallback.
9192 String get topicName {
9293 final topic = _obtainVocabularyTerm <String >("topic" );
9394
94- if (topic = = null ) {
95- throw MqttBindingException ( "MQTT topic was not defined on form." ) ;
95+ if (topic ! = null ) {
96+ return topic;
9697 }
9798
98- return topic;
99+ final path = Uri .decodeComponent (href.path);
100+
101+ if (path.isEmpty) {
102+ return path;
103+ }
104+
105+ return path.substring (1 );
99106 }
100107
101108 /// Gets the MQTT topic for subscribing from this [Form] .
You can’t perform that action at this time.
0 commit comments