@@ -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,26 @@ 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+ final hasJsParam = url.contains (_jsCompilerParam);
32+ final hasWasmParam = url.contains (_wasmCompilerParam) && ! hasJsParam;
2833 final basePath = uri.path;
2934 // Convert the URL by removing the fragment separator.
3035 final newUrl = url
36+ .replaceAll (_wasmCompilerParam, '' )
37+ .replaceAll (_jsCompilerParam, '' )
3138 // Handle localhost:123/#/inspector?uri=xxx
3239 .replaceFirst ('/#/' , '/' )
3340 // Handle localhost:123/#?page=inspector&uri=xxx
3441 .replaceFirst ('/#' , '' );
3542
3643 // Move page names from the querystring into the path.
3744 var newUri = Uri .parse (newUrl);
45+ final queryParams = {
46+ ...newUri.queryParameters,
47+ if (hasWasmParam) 'compiler' : 'wasm' ,
48+ if (hasJsParam) 'compiler' : 'js' ,
49+ };
50+ newUri = newUri.replace (queryParameters: queryParams);
3851 final page = newUri.queryParameters['page' ];
3952 if (newUri.path == basePath && page != null ) {
4053 final newParams = {...newUri.queryParameters}..remove ('page' );
0 commit comments