[flutter_tools] check for empty host in protocol_discovery (#83847)
This commit is contained in:
@@ -128,7 +128,7 @@ class ProtocolDiscovery {
|
||||
} on FormatException catch (error, stackTrace) {
|
||||
_uriStreamController.addError(error, stackTrace);
|
||||
}
|
||||
if (uri == null) {
|
||||
if (uri == null || uri.host.isEmpty) {
|
||||
return;
|
||||
}
|
||||
if (devicePort != null && uri.port != devicePort) {
|
||||
|
||||
@@ -24,7 +24,7 @@ void main() {
|
||||
ipv6: false,
|
||||
hostPort: null,
|
||||
devicePort: null,
|
||||
throttleDuration: const Duration(milliseconds: 200),
|
||||
throttleDuration: const Duration(milliseconds: 5),
|
||||
logger: BufferLogger.test(),
|
||||
);
|
||||
});
|
||||
@@ -47,6 +47,20 @@ void main() {
|
||||
expect('$uri', 'http://127.0.0.1:9999');
|
||||
});
|
||||
|
||||
testWithoutContext('does not discover uri with no host', () async {
|
||||
final Future<Uri> pendingUri = discoverer.uri;
|
||||
logReader.addLine('Observatory listening on http12asdasdsd9999');
|
||||
await Future<void>.delayed(const Duration(milliseconds: 10));
|
||||
logReader.addLine('Observatory listening on http://127.0.0.1:9999');
|
||||
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
|
||||
final Uri uri = await pendingUri;
|
||||
expect(uri, isNotNull);
|
||||
expect(uri.port, 9999);
|
||||
expect('$uri', 'http://127.0.0.1:9999');
|
||||
});
|
||||
|
||||
testWithoutContext('discovers uri if logs already produced output and no listener is attached', () async {
|
||||
logReader.addLine('HELLO WORLD');
|
||||
logReader.addLine('Observatory listening on http://127.0.0.1:9999');
|
||||
|
||||
Reference in New Issue
Block a user