Skip to content

Add NavigationManager.GetUriWithHash() extension method#64615

Merged
ilonatommy merged 7 commits intomainfrom
copilot/add-navigationmanager-geturiwithhash
Jan 21, 2026
Merged

Add NavigationManager.GetUriWithHash() extension method#64615
ilonatommy merged 7 commits intomainfrom
copilot/add-navigationmanager-geturiwithhash

Conversation

Copy link
Contributor

Copilot AI commented Dec 2, 2025

  • Merge with main branch and resolve conflicts
  • Make hash parameter non-nullable (now string instead of string?)
  • Add tests for non-root base URIs (e.g., when using <base href="/subdir/">)
  • Update test to add null check for hash parameter
  • Remove tests for null hash (now throws ArgumentNullException)
  • Revert googletest submodule changes

Summary of changes

  • Resolved merge conflicts in PublicAPI.Unshipped.txt
  • Changed GetUriWithHash signature to use non-nullable string hash parameter
  • Added ArgumentNullException.ThrowIfNull(hash) check
  • Changed string.IsNullOrEmpty(hash) to hash.Length == 0
  • Added test cases with non-root base paths
  • Reverted unintended googletest submodule pointer changes

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Copilot AI changed the title [WIP] Add NavigationManager.GetUriWithHash() method Add NavigationManager.GetUriWithHash() extension method Dec 2, 2025
Copilot AI requested a review from javiercn December 2, 2025 22:45
@javiercn javiercn marked this pull request as ready for review December 3, 2025 11:16
@javiercn javiercn requested a review from a team as a code owner December 3, 2025 11:16
Copilot AI review requested due to automatic review settings December 3, 2025 11:16
Copy link
Contributor

Copilot AI left a 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 adds a new GetUriWithHash() extension method to NavigationManager to address a longstanding issue with hash fragment URLs in Blazor applications. When a <base> element is used in the HTML document, relative hash URLs resolve against the base URI rather than the current document location, making it difficult to create in-page navigation links. The new API solves this by constructing absolute URIs with hash fragments relative to the current location.

Key Changes:

  • Added NavigationManager.GetUriWithHash() extension method that adds, updates, or removes hash fragments from the current URI
  • Comprehensive XML documentation with usage examples
  • Full test coverage including edge cases for hash manipulation

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/Components/Components/src/NavigationManagerExtensions.cs Implements the new GetUriWithHash() method with proper null checking, hash prepending logic, and URI manipulation
src/Components/Components/test/NavigationManagerTest.cs Adds comprehensive test coverage for the new method including hash addition, replacement, removal, and null parameter handling
src/Components/Components/src/PublicAPI.Unshipped.txt Documents the new public API surface for tracking purposes

Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
@ilonatommy
Copy link
Member

@javiercn, it happened again. Copilot is producing descriptions with random issue number next to "fixes" keyword. This one has nothing to do with 41773 (I won't be linking it to avoid confusion).

@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Dec 11, 2025
@ilonatommy
Copy link
Member

@copilot merge it with main and resolve conflicts

Copilot AI and others added 2 commits January 20, 2026 14:54
…non-root base URIs

Co-authored-by: ilonatommy <32700855+ilonatommy@users.noreply.github.com>
Copilot AI requested a review from wtgodbe as a code owner January 20, 2026 14:58
Copilot AI requested a review from a team as a code owner January 20, 2026 14:58
Copy link
Contributor Author

Copilot AI commented Jan 20, 2026

@copilot merge it with main and resolve conflicts

Merged with main and resolved conflicts (71c8945 and e2e4db0). The merge conflict in PublicAPI.Unshipped.txt has been resolved, keeping both the new API entries from main and our GetUriWithHash method.

@ilonatommy
Copy link
Member

@copilot remove src/submodules/googletest changes, it would be best if you check it out to main branch

Copilot AI and others added 2 commits January 20, 2026 15:15
Co-authored-by: ilonatommy <32700855+ilonatommy@users.noreply.github.com>
Co-authored-by: ilonatommy <32700855+ilonatommy@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 20, 2026

@copilot remove src/submodules/googletest changes, it would be best if you check it out to main branch

Reverted the googletest submodule changes to match the main branch (d3084c9 and b2a88c4). The submodule pointer has been restored to commit cb1bd881, which is the correct commit from the main branch.

@ilonatommy ilonatommy enabled auto-merge (squash) January 21, 2026 09:48
@ilonatommy ilonatommy merged commit fda5da4 into main Jan 21, 2026
25 checks passed
@ilonatommy ilonatommy deleted the copilot/add-navigationmanager-geturiwithhash branch January 21, 2026 12:11
@dotnet-policy-service dotnet-policy-service bot added this to the 11.0-preview1 milestone Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components Attention: Shared Code Modified pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants