File tree 1 file changed +13
-10
lines changed
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 {
62
62
63
63
throw StateError ('MQTT URI scheme $scheme is not supported.' );
64
64
}
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
+ }
65
75
}
66
76
67
77
/// Additional methods for making MQTT [Form] s easier to work with.
@@ -99,28 +109,21 @@ extension MqttFormExtension on Form {
99
109
return topic;
100
110
}
101
111
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;
109
113
}
110
114
111
115
/// Gets the MQTT topic for subscribing from this [Form] .
112
116
///
113
117
/// 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.
116
119
String get topicFilter {
117
120
final topic = _obtainVocabularyTerm <String >('filter' );
118
121
119
122
if (topic != null ) {
120
123
return topic;
121
124
}
122
125
123
- return Uri . decodeComponent ( href.query. replaceAll ( '&' , '/' )) ;
126
+ return href._mqttTopic ;
124
127
}
125
128
126
129
/// Gets the MQTT `retain` value from this [Form] if present.
You can’t perform that action at this time.
0 commit comments