@@ -139,7 +139,9 @@ class ThingDiscovery extends Stream<ThingDescription>
139139 return webLinks
140140 .where (
141141 (element) =>
142- element.attributes.getResourceTypes ()? .contains (resourceType) ??
142+ element.attributes
143+ .getResourceTypes ()
144+ ? .contains (resourceType.asCoreLinkFormatAttributeValue ()) ??
143145 false ,
144146 )
145147 .map ((weblink) => Uri .tryParse (weblink.uri))
@@ -148,8 +150,7 @@ class ThingDiscovery extends Stream<ThingDescription>
148150 }
149151
150152 Stream <ThingDescription > _discoverWithCoreLinkFormat (Uri uri) async * {
151- // TODO: Remove additional quotes once fixed in CoAP library
152- yield * _performCoreLinkFormatDiscovery ('"wot.thing"' , uri).transform (
153+ yield * _performCoreLinkFormatDiscovery ("wot.thing" , uri).transform (
153154 StreamTransformer .fromBind (
154155 (stream) async * {
155156 await for (final uris in stream) {
@@ -162,9 +163,7 @@ class ThingDiscovery extends Stream<ThingDescription>
162163 }
163164
164165 Stream <ThingDescription > _discoverfromCoreResourceDirectory (Uri uri) async * {
165- // TODO: Remove additional quotes once fixed in CoAP library
166- yield * _performCoreLinkFormatDiscovery ('"core.rd-lookup-res"' , uri)
167- .transform (
166+ yield * _performCoreLinkFormatDiscovery ("core.rd-lookup-res" , uri).transform (
168167 StreamTransformer .fromBind ((stream) async * {
169168 await for (final uris in stream) {
170169 for (final uri in uris) {
@@ -312,6 +311,12 @@ class ThingDiscovery extends Stream<ThingDescription>
312311 }
313312}
314313
314+ extension _CoreLinkFormatExtension on String {
315+ /// Formats this string as an attribute value for the CoRE Link-Format.
316+ // TODO: Remove additional quotes once fixed in CoAP library
317+ String asCoreLinkFormatAttributeValue () => '"$this "' ;
318+ }
319+
315320extension _UriExtension on Uri {
316321 /// Returns the [path] if it is not empty, otherwise `null` .
317322 String ? get _pathOrNull {
@@ -331,7 +336,9 @@ extension _UriExtension on Uri {
331336 /// the parameter name `rt` . If this name should already be in use, it will
332337 /// not be overridden.
333338 Uri toLinkFormatDiscoveryUri (String resourceType) {
334- final Map <String , dynamic > newQueryParameters = {"rt" : resourceType};
339+ final Map <String , dynamic > newQueryParameters = {
340+ "rt" : resourceType.asCoreLinkFormatAttributeValue (),
341+ };
335342 if (queryParameters.isNotEmpty) {
336343 newQueryParameters.addAll (queryParameters);
337344 }
0 commit comments