Skip to content

Commit 58c3b48

Browse files
authored
[Blazor] Fix JSInitializer URL computation for base URLs with query parameters (#63185)
1 parent 92237e2 commit 58c3b48

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Components/Web.JS/src/JSInitializers/JSInitializers.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ export class JSInitializer {
4949
await Promise.all(initializerFiles.map(f => importAndInvokeInitializer(this, f)));
5050

5151
function adjustPath(path: string): string {
52-
// This is the same we do in JS interop with the import callback
53-
const base = document.baseURI;
54-
path = base.endsWith('/') ? `${base}${path}` : `${base}/${path}`;
55-
return path;
52+
// Use URL constructor to properly resolve relative paths, avoiding issues with query parameters
53+
// This is the same mechanism as for import dotnet.js in MonoPlatform.ts
54+
return new URL(path, document.baseURI).toString();
5655
}
5756

5857
async function importAndInvokeInitializer(jsInitializer: JSInitializer, asset: JSAsset): Promise<void> {

0 commit comments

Comments
 (0)