Skip to content

Escaped Markdown links with spaces in them are not routed correctly #8867

@VladNastase

Description

@VladNastase

Have you read the Contributing Guidelines on issues?

Prerequisites

Description

Links that contain spaces have to be enclosed in pointy brackets (<>) according to the CommonMark specification (see here). In Docusaurus, the links are displayed properly, but are routed to the original filename (i.e. they also keep the original file extension). A link such as [Link](<./file 1.md>) will go to https://<yourwebsitehere>/<yourpathhere>/file%201.md if onBrokenLinks is set to warn and will completely fail the build process otherwise.

Reproducible demo

https://vladnastase.github.io/docusaurus-bug/chapter1/doc

Steps to reproduce

  1. Create a file with a space in its name.
  2. Link to it using a Markdown link (do not forget to properly enclose it in pointy brackets).
  3. (Optional) Set onBrokenLinks to warn in docusaurus.config.js.
  4. Build the website and try the link, or observe the error.

Expected behavior

Build succeeds if onBrokenLinks is not set to warn, link works properly otherwise.

In the linked reproduction, links 2 and 3 should go to https://vladnastase.github.io/docusaurus-bug/chapter1/doc%202 and https://vladnastase.github.io/docusaurus-bug/chapter%202/doc1 respectively (instead of https://vladnastase.github.io/docusaurus-bug/chapter1/doc%202.md and https://vladnastase.github.io/docusaurus-bug/chapter%202/doc1.md)

Actual behavior

Build fails if onBrokenLinks is not set to warn, links don't work properly (they keep the original file extension).

Your environment

Self-service

  • I'd be willing to fix this bug myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its executiongood first issueIf you are just getting started with Docusaurus, this issue should be a good place to begin.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions