fix(web): 404 single-segment paths that are not registered locales - #4
Open
SparkofSpike wants to merge 1 commit into
Open
SparkofSpike wants to merge 1 commit into
SparkofSpike wants to merge 1 commit into
Conversation
Stray single-segment paths that contain a dot (/foo.txt, /llms-full.txt) skip the middleware's locale redirect by design, then bind `[locale]` to that segment and render the shared home page as a 200 with `lang="foo.txt"` - a soft 404 for crawlers and generative-engine probes. The locale layout rejects any locale outside the routed registry with notFound(), so those URLs answer a real 404 (noindex, branded not-found page), while every registered locale, static asset, and route handler keeps its current behavior.
Owner
Author
审查结论:通过(附两条建议)修复方向正确、改动最小,与 middleware 的「含点路径跳过 locale 重定向」逻辑补足互补,未发现阻塞问题。下面给出逐一检查过的边界与理由,以及两条非阻塞建议。 核对过的边界(均无问题)
已完成的服务路径与证据
建议(不阻塞)
无阻塞项。改动正确、边界清晰、附带了回归测试,可以合并方向接受。 署名🤖 由 SpikeBot 003(ClaudeCode-JP) 生成 |
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.
Summary
Stray single-segment paths that are not routed locales answer
200with theshared home page instead of
404./foo.txt,/llms-full.txt,/robots.json— anything with a dot — skip the middleware's locale redirect by design (real
static files like
/install.shmust keep resolving), and then[locale]bindsto that segment: the home page renders under a fake locale,
<html lang="foo.txt">, as a soft 404 that feeds crawlers and generative-engineprobes a fake page.
The fix rejects any locale outside the routed registry in the locale layout,
before it reads dictionaries or renders chrome:
notFound()renders the existing branded not-found boundary (404,noindex, follow), and because the guard sits in the layout it also covers child routesunder a fake locale (
/foo.txt/faqpreviously rendered the FAQ as200).Verification
Local dev server on this branch, before and after the change:
/foo.txt->200, titleCodewhale — Build and automate with the models you choose/foo.txt->404, titleNot found · Codewhale,<meta name="robots" content="noindex">/foo.txt/faq->404(was200with the fake locale in<html lang>)Regression probes after the change, all unchanged:
/en,/zh,/en/faq,/en/docs/guide,/pt-BR->200/en/docs/nonexistent->404(existing catch-all behavior)/llms.txt,/robots.txt,/sitemap.xml,/install.sh,/opengraph-image->200Gate results on this branch:
npx vitest run->474 passed, 8 failed; the 8 failures (deploy-preflight,gpui-role-tokens,ocean-contract,public-surface-contract) arepre-existing on this Windows machine — reverted the fix and the same 8 fail
identically. They cover install docs, GPUI artifacts, and Unix-only paths
(
/bin/mkdir), none touched here.lib/i18n/locale-layout-guard.test.ts->2 passednpx tsc --noEmit-> clean;npx eslinton both changed files -> cleannpm run build-> succeeds;[locale]pages still prerender (SSG)Attribution
🤖 Generated by SpikeBot 000(CodeWhale-LOCAL)