@@ -14,6 +14,9 @@ String extractCurrentPageFromUrl(String url) {
1414 : uri.path.substring (1 );
1515}
1616
17+ const _jsCompilerParam = '?compiler=js' ;
18+ const _wasmCompilerParam = '?compiler=wasm' ;
19+
1720/// Maps DevTools URLs in the original fragment format onto the equivalent URLs
1821/// in the new URL format.
1922///
@@ -25,16 +28,29 @@ String? mapLegacyUrl(String url) {
2528 // http://localhost:123/#/?page=inspector&uri=ws://...
2629 final isRootRequest = uri.path == '/' || uri.path.endsWith ('/devtools/' );
2730 if (isRootRequest && uri.fragment.isNotEmpty) {
31+ // Note: If there is a ?compiler= query parameter, we remove it from before
32+ // the hash then add it back in as a query parameter at the end.
33+ // See https://github.com/flutter/devtools/issues/9612 for details.
34+ final hasJsParam = url.contains (_jsCompilerParam);
35+ final hasWasmParam = url.contains (_wasmCompilerParam) && ! hasJsParam;
2836 final basePath = uri.path;
2937 // Convert the URL by removing the fragment separator.
3038 final newUrl = url
39+ .replaceAll (_jsCompilerParam, '' )
40+ .replaceAll (_wasmCompilerParam, '' )
3141 // Handle localhost:123/#/inspector?uri=xxx
3242 .replaceFirst ('/#/' , '/' )
3343 // Handle localhost:123/#?page=inspector&uri=xxx
3444 .replaceFirst ('/#' , '' );
3545
3646 // Move page names from the querystring into the path.
3747 var newUri = Uri .parse (newUrl);
48+ final queryParams = {
49+ ...newUri.queryParameters,
50+ if (hasJsParam) 'compiler' : 'js' ,
51+ if (hasWasmParam) 'compiler' : 'wasm' ,
52+ };
53+ newUri = newUri.replace (queryParameters: queryParams);
3854 final page = newUri.queryParameters['page' ];
3955 if (newUri.path == basePath && page != null ) {
4056 final newParams = {...newUri.queryParameters}..remove ('page' );
0 commit comments