Skip to content

bug: LeetCode 页面中文路径在 Linux 服务器上 404 #273

Description

@longsizhuo

问题描述

LeetCode 目录下,文件名含有中文字符的页面在线上无法访问,点击后直接 404。

感谢

感谢 @plural0135 在 Discussion #269 中发现并反馈了这个问题:

"leetcode很多link打不开,比如:https://involutionhell.com/docs/CommunityShare/Leetcode/%5B1333%5D%E9%A4%90%E5%8E%85%E8%BF%87%E6%BB%A4%E5%99%A8_translated"

根因

Fumadocs 在构建时会将文件名直接转换为 URL slug。当文件名包含中文字符(如 [121]买卖股票的最佳时期.md),slug 会被 URL encode 成 %5B121%5D%E4%B9%B0%E5%8D%96...

  • macOS(APFS):文件系统底层有 case-insensitive 匹配和自动纠错,本地开发无感知,页面正常访问
  • Linux 服务器(Vercel / Docker):文件系统严格区分大小写和路径,URL encode 后的路径无法被正确解析,直接 404

修复方案

PR #272 引入 pinyin-pro 库,在 lib/source.ts 中挂载一个 Fumadocs transformer,在构建时将 CommunityShare/Leetcode/ 目录下所有文件的中文 slug 自动转换为拼音路径。

不改动文件名,不影响 Git 历史,仅在路由层做映射。

复现路径

访问任意含中文文件名的 LeetCode 页面,如:
https://involutionhell.com/docs/CommunityShare/Leetcode/%5B121%5D%E4%B9%B0%E5%8D%96%E8%82%A1%E7%A5%A8%E7%9A%84%E6%9C%80%E4%BD%B3%E6%97%B6%E6%9C%9F_translated

关联

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions