|
10 | 10 | using System.Text.Json;
|
11 | 11 | using System.Text.Json.Serialization;
|
12 | 12 | using Microsoft.AspNetCore.Http;
|
| 13 | +using Microsoft.AspNetCore.Http.Extensions; |
13 | 14 | using System.Dynamic;
|
14 | 15 |
|
15 | 16 | namespace Microsoft.AspNetCore.Components.WebAssembly.Server;
|
@@ -366,9 +367,31 @@ private string GetDevToolsUrlWithProxy(BrowserTab tabToDebug)
|
366 | 367 | {
|
367 | 368 | var underlyingV8Endpoint = new Uri(tabToDebug.WebSocketDebuggerUrl);
|
368 | 369 | var proxyEndpoint = new Uri(_debugProxyUrl);
|
369 |
| - var devToolsUrlAbsolute = new Uri(_browserHost + tabToDebug.DevtoolsFrontendUrl); |
| 370 | + var devToolsUrlAbsolute = new Uri(new Uri(_browserHost), relativeUri: NormalizeDevtoolsFrontendUrl(tabToDebug.DevtoolsFrontendUrl)); |
370 | 371 | var devToolsUrlWithProxy = $"{devToolsUrlAbsolute.Scheme}://{devToolsUrlAbsolute.Authority}{devToolsUrlAbsolute.AbsolutePath}?{underlyingV8Endpoint.Scheme}={proxyEndpoint.Authority}{underlyingV8Endpoint.PathAndQuery}";
|
371 | 372 | return devToolsUrlWithProxy;
|
| 373 | + |
| 374 | + static string NormalizeDevtoolsFrontendUrl(string devtoolsFrontendUrl) |
| 375 | + { |
| 376 | + // Currently frontend url can be: |
| 377 | + // - absolute (since v135 of chrome and edge) |
| 378 | + // chrome example: https://chrome-devtools-frontend.appspot.com/serve_rev/@031848bc6ad02b97854f3d6154d3aefd0434756a/inspector.html?ws=localhost:9222/devtools/page/719FE9D3B43570193235446E0AB36859 |
| 379 | + // edge example: https://aka.ms/docs-landing-page/serve_rev/@4e2c41645f24197463afa2ab6aa999352ee8255c/inspector.html?ws=localhost:9222/devtools/page/3A4D56E09776321628432588FC9299F4 |
| 380 | + // - relative (managed as fallback for brosers with prior version) |
| 381 | + // example: /devtools/inspector.html?ws=localhost:9222/devtools/page/DAB7FB6187B554E10B0BD18821265734 |
| 382 | + // The absolute url can't be used as-is because is not valid for debugging and cannot be made relative because of lack "devtools" segment |
| 383 | + // before "inspector.html" but we can keep the query string and append to the default "devtools/inspector.html" browser devtools page |
| 384 | + |
| 385 | + const string DefaultBrowserDevToolsPagePath = "devtools/inspector.html"; |
| 386 | + |
| 387 | + if (devtoolsFrontendUrl.AsSpan().TrimStart('/').StartsWith(DefaultBrowserDevToolsPagePath)) |
| 388 | + { |
| 389 | + return devtoolsFrontendUrl; |
| 390 | + } |
| 391 | + |
| 392 | + UriHelper.FromAbsolute(devtoolsFrontendUrl, out _, out _, out _, out var query, out _); |
| 393 | + return $"{DefaultBrowserDevToolsPagePath}{query}"; |
| 394 | + } |
372 | 395 | }
|
373 | 396 |
|
374 | 397 | private string GetLaunchChromeInstructions(string targetApplicationUrl)
|
|
0 commit comments