mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #1069] [MERGED] refactor(i18n): dedupe NEXT_LOCALE cookie parsing #1067
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#1067
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/1069
Author: @james-elicx
Created: 5/5/2026
Status: ✅ Merged
Merged: 5/5/2026
Merged by: @james-elicx
Base:
main← Head:refactor/dedupe-locale-cookie-parsing📝 Commits (1)
229d38drefactor(i18n): dedupe NEXT_LOCALE cookie parsing📊 Changes
1 file changed (+0 additions, -10 deletions)
View changed files
📝
packages/vinext/src/entries/pages-server-entry.ts(+0 -10)📄 Description
Summary
parseCookieLocaleFromHeaderhelper from the Pages SSR entry template (packages/vinext/src/entries/pages-server-entry.ts). It duplicated the regex +decodeURIComponentpattern already exported frompackages/vinext/src/server/pages-i18n.ts.resolvePagesI18nRequest, which already calls the canonicalparseCookieLocaleFromHeaderfrompages-i18n.tsinternally.Why deletion rather than import-and-call
I started by checking whether the entry should
import { parseCookieLocaleFromHeader }frompages-i18n.ts. It turns out the local copy in the entry template is dead code: defined inside the SSR-entry template literal but never invoked. The single locale-resolution call site (_renderPage) already delegates toresolvePagesI18nRequest, so the cleanest dedupe is removal of the duplicate definition rather than a dangling import.The two implementations were behaviorally equivalent (same regex
/(?:^|;\s*)NEXT_LOCALE=([^;]*)/, samedecodeURIComponent(match[1].trim()), same allow-list check againsti18nConfig.locales). No behavior change.Files changed
packages/vinext/src/entries/pages-server-entry.ts— remove deadparseCookieLocaleFromHeader(10 lines deleted).Out-of-scope notes
Two adjacent helpers in the same template are also dead code:
extractLocaleanddetectLocaleFromHeaders. Left untouched per "only fix what's in scope" — happy to clean them up in a separate PR.Test plan
pnpm vp test run tests/pages-router.test.ts— 200/200 passpnpm fmt --writeon touched file🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.