Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug report] 以文件路径作为超链接,且该文件定义了permalink时,路由解析跳转到 404 #1516

Closed
pengzhanbo opened this issue Mar 19, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@pengzhanbo
Copy link
Member

pengzhanbo commented Mar 19, 2024

Description

当 md 文件名中包含 中文时,且 该文件定义了 frontmatter.permalink
如果使用了 [xxx](./测试1.md) 用文件名作为跳转链接,将会跳转到 404。

初步排查是由于 文件路径编码引发。
/core/src/app/prepare/prepareRoutes.ts ,在生成 redirects 时,redirect 使用的是 未编码的 文件路径。
而在 linksPlugin 中,生成 链接路径的 resolvePaths 函数中会对 文件路径进行 编码。
导致在 client 端中的 resolveRoutePath 函数 未查找到 重定向地址。
router.beforeResolve 钩子跳转到了 404 。

Reproduction

https://stackblitz.com/edit/vuepress-svx1ub?file=docs%2FREADME.md

Used Package Manager

pnpm

System Info

System:
    OS: macOS 14.2.1
  Binaries:
    Node: 21.3.0 
    Yarn: 1.22.19 
    npm: 10.2.4 
    pnpm: 8.15.4 
    bun: Not Found
  Browsers:
    Chrome: 122.0.6261.129
    Edge: Not Found
    Safari: 17.2.1
  npmPackages:
    @vuepress/bundler-vite: 2.0.0-rc.8 => 2.0.0-rc.8 
    @vuepress/bundler-webpack: Not Found
    @vuepress/cli: Not Found
    @vuepress/client: Not Found
    @vuepress/core: Not Found
    @vuepress/markdown: Not Found
    @vuepress/shared: Not Found
    @vuepress/utils: Not Found
    vue: ^3.4.21 => 3.4.21 
    vue-router: Not Found
    vuepress: ^2.0.0-rc.8 => 2.0.0-rc.8
@meteorlxy
Copy link
Member

image

这个应该是正常访问吧?

@meteorlxy meteorlxy added the bug Something isn't working label Mar 20, 2024
@pengzhanbo
Copy link
Member Author

image 这个应该是正常访问吧?

是的,可以访问,我标记错了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants