[flutter_tools] convert devtools URL to a better format (#85170)
This commit is contained in:
@@ -288,3 +288,13 @@ class NoOpDevtoolsHandler implements ResidentDevtoolsHandler {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert a [URI] with query parameters into a display format instead
|
||||
/// of the default URI encoding.
|
||||
String urlToDisplayString(Uri uri) {
|
||||
final StringBuffer base = StringBuffer(uri.replace(
|
||||
queryParameters: <String, String>{},
|
||||
).toString());
|
||||
base.write(uri.queryParameters.keys.map((String key) => '$key=${uri.queryParameters[key]}').join('&'));
|
||||
return base.toString();
|
||||
}
|
||||
|
||||
@@ -1409,7 +1409,7 @@ abstract class ResidentRunner extends ResidentHandlers {
|
||||
if (uri != null) {
|
||||
globals.printStatus(
|
||||
'The Flutter DevTools debugger and profiler '
|
||||
'on ${device.device.name} is available at: $uri',
|
||||
'on ${device.device.name} is available at: ${urlToDisplayString(uri)}',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -427,6 +427,13 @@ void main() {
|
||||
expect(handler.launchDevToolsInBrowser(flutterDevices: <FlutterDevice>[]), isTrue);
|
||||
expect(handler.launchedInBrowser, isTrue);
|
||||
});
|
||||
|
||||
testWithoutContext('Converts a VmService URI with a query parameter to a pretty display string', () {
|
||||
const String value = 'http://127.0.0.1:9100?uri=http%3A%2F%2F127.0.0.1%3A57922%2F_MXpzytpH20%3D%2F';
|
||||
final Uri uri = Uri.parse(value);
|
||||
|
||||
expect(urlToDisplayString(uri), 'http://127.0.0.1:9100?uri=http://127.0.0.1:57922/_MXpzytpH20=/');
|
||||
});
|
||||
}
|
||||
|
||||
class FakeDevtoolsLauncher extends Fake implements DevtoolsLauncher {
|
||||
|
||||
Reference in New Issue
Block a user