Skip to content

dead link errors should show transformed URL #3774

Open
@vincesp

Description

Describe the bug

This bug was not present in v1.0.0-rc.24 but is now present in v1.1.0.

  • Create a file with the file extension .crt in the public folder
  • Link to that file from a Markdown file

Current behavior:

  • During page generation, the file extension .html is added after the file extension .crt
  • This results in a dead link
  • Fortunately, the dead link checker picks up the dead link and reports it, which results in a failed build. Unfortunately, the error message is misleading. It prints the original file name "/some-root-ca.crt" which would not be a dead link instead of the corrupted file name "/some-root-ca.crt.html" which is the actual dead link.

Reproduction

https://stackblitz.com/edit/vite-ezwnqb?file=docs%2Fexample.md

  • Run npm run docs:dev
  • Navigate to the Example page
  • There are 2 links
    • The link to the txt file will work
    • The link to the crt file is corrupted, points to /some-root-ca.crt.html instead of /some-root-ca.crt
  • Run npm run docs:build
  • The following error will be displayed:
    (!) Found dead link /some-root-ca.crt in file example.md
    
    If this is expected, you can disable this check via config. Refer: https://vitepress.dev/reference/site-config#ignoredeadlinks
    
    x Build failed in 1.81s
    ✖ building client + server bundles...
    build error:
    Error: [vitepress] 1 dead link(s) found.
        at Object.renderStart (/home/projects/vite-ezwnqb/node_modules/vitepress/dist/node/serve-Csn-CKFx.js:42382:15)
        at eval (/home/projects/vite-ezwnqb/node_modules/rollup/dist/es/shared/node-entry.js:19622:40)
        at async PluginDriver.hookParallel (/home/projects/vite-ezwnqb/node_modules/rollup/dist/es/shared/node-entry.js:19550:9)
        at async Bundle.generate (/home/projects/vite-ezwnqb/node_modules/rollup/dist/es/shared/node-entry.js:17980:13)
        at async eval (/home/projects/vite-ezwnqb/node_modules/rollup/dist/es/shared/node-entry.js:20539:27)
        at async catchUnfinishedHookActions (/home/projects/vite-ezwnqb/node_modules/rollup/dist/es/shared/node-entry.js:19967:16)
    
    Note that the link displayed is not a dead link. The error message does not tell that it in fact tries to link to /some-root-ca.crt.html which does not exist.

Expected behavior

Behavior like in v1.0.0-rc.24:

https://stackblitz.com/edit/vite-5ovzcs?file=package.json

  • Link target is not being changed during page generation
  • No dead link detected during build

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.3 - /usr/local/bin/pnpm
  npmPackages:
    vitepress: latest => 1.1.0

Additional context

No response

Validations

Metadata

Assignees

No one assigned

    Labels

    docsImprovements or additions to documentationenhancementNew feature or requeststale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions