fix: 讓 /{lang}/index.json 回傳字詞串列 (close #124)#125
Merged
Conversation
/a、/t、/h、/c 的 index.json 原本會被當成一般詞彙查詢,導致 404
(萌典閃卡使用的 /c/index.json 即受影響)。在 handleLanguageSubRoute
中加入 text === 'index' 的特例,直接回傳 R2 的 {lang}/index.json,
與 /api/index/{lang}.json 對齊。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
字詞串列原本以壓縮 JSON 回傳,全部擠在一行。改為 pretty 格式 (JSON.stringify(payload, null, 2)),每個詞彙獨立一行、逗號後換行, 排版較易閱讀。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
問題
以下四個路由原本應回傳字詞串列,但目前會被當成一般詞彙「index」查詢,查不到即回 404:
/a/index.json/t/index.json/h/index.json/c/index.json其中
/c/index.json為萌典閃卡所使用,目前回傳 404。修法(最小更動)
字詞串列其實已存在於 R2 的
{lang}/index.json,並已透過/api/index/{lang}.json對外提供。本 PR 在handleLanguageSubRoute加入text === 'index'的特例,直接回傳 R2 的{lang}/index.json,行為與/api/index/{lang}.json對齊(找不到時回 404)。測試
/{lang}/index.json四個語系回傳陣列(tests/integration/api-index-xref-search.test.ts)tests/unit/api-handlers-direct.test.ts,符合 CLAUDE.md 對 handler 分支需 direct-call 覆蓋的要求)驗證:
typecheck✅、lint✅、test:unit(856 passed,覆蓋率 ratchet 維持)✅、test:integration(74 passed)✅Close #124
🤖 Generated with Claude Code