@@ -9,12 +9,8 @@ import "package:mqtt_client/mqtt_client.dart";
99import "package:mqtt_client/mqtt_server_client.dart" ;
1010import "package:uuid/uuid.dart" ;
1111
12- import '../../core.dart' ;
13- import '../definitions/form.dart' ;
14- import '../definitions/security/auto_security_scheme.dart' ;
15- import '../definitions/security/basic_security_scheme.dart' ;
16- import '../definitions/validation/validation_exception.dart' ;
17- import 'constants.dart' ;
12+ import "../../core.dart" ;
13+ import "constants.dart" ;
1814
1915/// [PrefixMapping] for expanding MQTT Vocabulary terms from compact IRIs.
2016final mqttPrefixMapping = PrefixMapping (defaultPrefixValue: mqttContextUri);
@@ -62,6 +58,16 @@ extension MqttUriExtension on Uri {
6258
6359 throw StateError ("MQTT URI scheme $scheme is not supported." );
6460 }
61+
62+ String get _mqttTopic {
63+ final path = Uri .decodeComponent (this .path);
64+
65+ if (path.isEmpty) {
66+ return path;
67+ }
68+
69+ return path.substring (1 );
70+ }
6571}
6672
6773/// Additional methods for making MQTT [Form] s easier to work with.
@@ -99,28 +105,21 @@ extension MqttFormExtension on AugmentedForm {
99105 return topic;
100106 }
101107
102- final path = Uri .decodeComponent (href.path);
103-
104- if (path.isEmpty) {
105- return path;
106- }
107-
108- return path.substring (1 );
108+ return href._mqttTopic;
109109 }
110110
111111 /// Gets the MQTT topic for subscribing from this [Form] .
112112 ///
113113 /// 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.
114+ /// Otherwise, the URI path from the `href` field is being used as a fallback.
116115 String get topicFilter {
117116 final topic = _obtainVocabularyTerm <String >("filter" );
118117
119118 if (topic != null ) {
120119 return topic;
121120 }
122121
123- return Uri . decodeComponent ( href.query. replaceAll ( "&" , "/" )) ;
122+ return href._mqttTopic ;
124123 }
125124
126125 /// Gets the MQTT `retain` value from this [Form] if present.
0 commit comments