-
Notifications
You must be signed in to change notification settings - Fork 10.4k
[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
base: main
Are you sure you want to change the base?
Conversation
Greetings human! You've submitted a PR that modifies code that is shared with https://github.com/dotnet/runtime . Please make sure you synchronize this code with the changes in that repo! |
Co-authored-by: maraf <[email protected]>
…functionality Co-authored-by: javiercn <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a URL resolution bug in the JSInitializer's adjustPath
function where string concatenation was creating malformed URLs when the document base URI contained query parameters or other URL components.
Key changes:
- Replaced string concatenation with the URL constructor for proper URL resolution
- Aligned implementation with the pattern used in MonoPlatform.ts
- Added comprehensive test coverage for various URL scenarios
The JSInitializer
adjustPath
function was using string concatenation to build URLs, which created malformed URLs when the document base URI contained query parameters or other URL components.Problem:
When
document.baseURI
ishttp://domain?a=x
, the string concatenation approach would create:This is a malformed URL with the path incorrectly placed after the query string.
Solution:
Replace string concatenation with the URL constructor, following the same pattern used in
MonoPlatform.ts
:Result:
The same scenario now correctly produces:
This change ensures proper URL resolution according to web standards, where query parameters and fragments in the base URL are handled correctly when resolving relative paths.
Added comprehensive tests covering various URL scenarios including query parameters, fragments, trailing slashes, and subdirectories.
Fixes #63184.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.