Updates packages (#41936)
diff --git a/packages/flutter_tools/lib/src/mdns_discovery.dart b/packages/flutter_tools/lib/src/mdns_discovery.dart
index f94788d..8b39756 100644
--- a/packages/flutter_tools/lib/src/mdns_discovery.dart
+++ b/packages/flutter_tools/lib/src/mdns_discovery.dart
@@ -115,22 +115,19 @@
if (txt == null || txt.isEmpty) {
return MDnsObservatoryDiscoveryResult(srv.first.port, '');
}
- String authCode = '';
const String authCodePrefix = 'authCode=';
- String raw = txt.first.text;
- // TXT has a format of [<length byte>, text], so if the length is 2,
- // that means that TXT is empty.
- if (raw.length > 2) {
- // Remove length byte from raw txt.
- raw = raw.substring(1);
- if (raw.startsWith(authCodePrefix)) {
- authCode = raw.substring(authCodePrefix.length);
- // The Observatory currently expects a trailing '/' as part of the
- // URI, otherwise an invalid authentication code response is given.
- if (!authCode.endsWith('/')) {
- authCode += '/';
- }
- }
+ final String raw = txt.first.text.split('\n').firstWhere(
+ (String s) => s.startsWith(authCodePrefix),
+ orElse: () => null,
+ );
+ if (raw == null) {
+ return MDnsObservatoryDiscoveryResult(srv.first.port, '');
+ }
+ String authCode = raw.substring(authCodePrefix.length);
+ // The Observatory currently expects a trailing '/' as part of the
+ // URI, otherwise an invalid authentication code response is given.
+ if (!authCode.endsWith('/')) {
+ authCode += '/';
}
return MDnsObservatoryDiscoveryResult(srv.first.port, authCode);
} finally {