[BUGFIX] Prevent infinite redirect loop by validating URL hash formatting #288
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Description
This PR fixes the infinite redirect loop that occurs when a user attempts to switch the application language.
The core of the issue was located in
lib/utils/router.tswithin thecustomRoutefunction. Previously, the code updated thelocation.hashby unconditionally prepending a forward slash to thematch.hashString. Sincematch.hashStringoften already contained a leading slash, this resulted in malformed URLs (e.g.,//de/map). These malformed paths failed to satisfy the router's regex requirements, causing the application to fail to recognize the state and trigger another reload, thus starting the loop.The Fix:
The logic now checks for the existence of a leading slash in
match.hashStringbefore constructing the final URL hash.Motivation and Context
How Has This Been Tested?
#/de/map) and correctly initialized translations.npm run buildto confirm the changes compile correctly within the project structure.Checklist: