Unverified Commit ff5258a5 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] convert devtools URL to a better format (#85170)

parent ad540e4f
...@@ -288,3 +288,13 @@ class NoOpDevtoolsHandler implements ResidentDevtoolsHandler { ...@@ -288,3 +288,13 @@ class NoOpDevtoolsHandler implements ResidentDevtoolsHandler {
return; 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 { ...@@ -1409,7 +1409,7 @@ abstract class ResidentRunner extends ResidentHandlers {
if (uri != null) { if (uri != null) {
globals.printStatus( globals.printStatus(
'The Flutter DevTools debugger and profiler ' '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() { ...@@ -427,6 +427,13 @@ void main() {
expect(handler.launchDevToolsInBrowser(flutterDevices: <FlutterDevice>[]), isTrue); expect(handler.launchDevToolsInBrowser(flutterDevices: <FlutterDevice>[]), isTrue);
expect(handler.launchedInBrowser, 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 { class FakeDevtoolsLauncher extends Fake implements DevtoolsLauncher {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment