File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,16 @@ extension MqttUriExtension on Uri {
6262
6363 throw StateError ('MQTT URI scheme $scheme is not supported.' );
6464 }
65+
66+ String get _mqttTopic {
67+ final path = Uri .decodeComponent (this .path);
68+
69+ if (path.isEmpty) {
70+ return path;
71+ }
72+
73+ return path.substring (1 );
74+ }
6575}
6676
6777/// Additional methods for making MQTT [Form] s easier to work with.
@@ -99,28 +109,21 @@ extension MqttFormExtension on Form {
99109 return topic;
100110 }
101111
102- final path = Uri .decodeComponent (href.path);
103-
104- if (path.isEmpty) {
105- return path;
106- }
107-
108- return path.substring (1 );
112+ return href._mqttTopic;
109113 }
110114
111115 /// Gets the MQTT topic for subscribing from this [Form] .
112116 ///
113117 /// If present, this getter uses the dedicated vocabulary term `filter` .
114- /// Otherwise, the URI query from the `href` field is being used as a
115- /// fallback.
118+ /// Otherwise, the URI path from the `href` field is being used as a fallback.
116119 String get topicFilter {
117120 final topic = _obtainVocabularyTerm <String >('filter' );
118121
119122 if (topic != null ) {
120123 return topic;
121124 }
122125
123- return Uri . decodeComponent ( href.query. replaceAll ( '&' , '/' )) ;
126+ return href._mqttTopic ;
124127 }
125128
126129 /// Gets the MQTT `retain` value from this [Form] if present.
You can’t perform that action at this time.
0 commit comments