Skip to content

[Blazor] Fix JSInitializer URL computation for base URLs with query parameters #63185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/Components/Web.JS/src/JSInitializers/JSInitializers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ export class JSInitializer {
await Promise.all(initializerFiles.map(f => importAndInvokeInitializer(this, f)));

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

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