fix: Improve base path detection for setting a cookie - #2410
Merged
Merged
Conversation
|
@soroush5 is attempting to deploy a commit to the next-intl Team on Vercel. A member of the Team first needs to authorize it. |
Returning the window pathname in that case would scope the locale cookie to the current page instead of the app root. Also adds a test for the fallback branch. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
amannn
reviewed
Sep 11, 2026
Co-authored-by: Jan Amann <jan@amann.work>
Owner
|
Added some minor changes, looks good to me now. |
This was referenced Sep 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I ran into this with a base path that contains the current pathname as a substring.
Repro: app mounted under
/dashboard, user on/dashboard/dash, sogetBasePath('/dash', '/dashboard/dash')runs. The old code did a first-occurrence replace and returned/board/dash, which is garbage and breaks navigation under that base path.This change only strips the pathname when it's actually the trailing part of the window path, and leaves the window path untouched otherwise. I added cases for
/dashunder/dashboardand/docunder/docs.Tests: the
getBasePathsuite inutils.test.tsxpasses (18/18).