@@ -9,12 +9,8 @@ import "package:mqtt_client/mqtt_client.dart";
9
9
import "package:mqtt_client/mqtt_server_client.dart" ;
10
10
import "package:uuid/uuid.dart" ;
11
11
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" ;
18
14
19
15
/// [PrefixMapping] for expanding MQTT Vocabulary terms from compact IRIs.
20
16
final mqttPrefixMapping = PrefixMapping (defaultPrefixValue: mqttContextUri);
@@ -62,6 +58,16 @@ extension MqttUriExtension on Uri {
62
58
63
59
throw StateError ("MQTT URI scheme $scheme is not supported." );
64
60
}
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
+ }
65
71
}
66
72
67
73
/// Additional methods for making MQTT [Form] s easier to work with.
@@ -99,28 +105,21 @@ extension MqttFormExtension on AugmentedForm {
99
105
return topic;
100
106
}
101
107
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;
109
109
}
110
110
111
111
/// Gets the MQTT topic for subscribing from this [Form] .
112
112
///
113
113
/// 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.
116
115
String get topicFilter {
117
116
final topic = _obtainVocabularyTerm <String >("filter" );
118
117
119
118
if (topic != null ) {
120
119
return topic;
121
120
}
122
121
123
- return Uri . decodeComponent ( href.query. replaceAll ( "&" , "/" )) ;
122
+ return href._mqttTopic ;
124
123
}
125
124
126
125
/// Gets the MQTT `retain` value from this [Form] if present.
0 commit comments