fix: preserve asset URLs when trailingSlash is enabled - #12323
Conversation
|
Hi @Sudemc! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Pre-flight checklist
Motivation
Fixes #6282.
When
trailingSlash: trueis enabled, generated Markdown asset URLs are treated like internal routes by theLinkcomponent. This appends a trailing slash to URLs such as/assets/files/example.docx, causing the browser to request an invalid asset path.The MDX transform already knows when a link resolves to a real asset file. This change carries that information to
Linkthrough an internal marker so only confirmed asset URLs skip route-specific trailing-slash normalization. Normal internal routes keep their existing behavior.Summary
Linkwithout forwarding it to the DOMLinkbehaviorTest plan
pnpm test packages/docusaurus/src/client/exports/__tests__/Link.test.tsx packages/docusaurus-mdx-loader/src/remark/transformLinks/__tests__/index.test.tspnpm --filter @docusaurus/core buildpnpm --filter @docusaurus/mdx-loader buildAll 38 targeted tests pass, and both affected packages build successfully with Node.js 24.14.
Test links
Related issues/PRs
This contribution was AI-assisted. The implementation and generated changes were manually reviewed and verified.