docusaurus icon indicating copy to clipboard operation
docusaurus copied to clipboard

Cannot resolve links when folders have periods in the name

Open adunndevster2 opened this issue 2 years ago • 1 comments

Have you read the Contributing Guidelines on issues?

Prerequisites

  • [X] I'm using the latest version of Docusaurus.
  • [X] I have tried the npm run clear or yarn clear command.
  • [X] I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • [X] I have tried creating a repro with https://new.docusaurus.io.
  • [X] I have read the console error message carefully (if applicable).

Description

I'm trying to link to docs in my docset that have periods "." in the folder name. * Meadow.Foundation for example.

This doesn't work though and give me the error Module not found: Error: Can't resolve './../../Meadow.Foundation' in '/Users/adam/_/Documentation/docs/Meadow/Getting_Started/Getting_Started_Core-Compute_Module'

I've confirmed it's due to the period in the folder name. Is there a way we can keep periods in our folder names and get this to work?

Reproducible demo

https://github.com/WildernessLabs/Documentation/tree/docusaurus

Steps to reproduce

  1. Have a folder that has a period in its name
  2. Create a link to a document within that folder
  3. npm start
  4. You should see that it can't resolve that link

Expected behavior

Please resolve links to documents within folders that have periods in their names 🙏🏻

Actual behavior

Module not found: Error: Can't resolve './../../Meadow.Foundation' in '/Users/adam//Documentation/docs/Meadow/Getting_Started/Getting_Started_Core-Compute_Module' Module not found: Error: Can't resolve './../../Meadow.Foundation' in '/Users/adam//Documentation/docs/Meadow/Getting_Started/Hello_World' Module not found: Error: Can't resolve './Maple.Server' in '/Users/adam//Documentation/docs/Meadow/Meadow.Foundation/Libraries_and_Frameworks' Module not found: Error: Can't resolve './../../Meadow.Foundation/Libraries_and_Frameworks/Maple.Server' in '/Users/adam//Documentation/docs/Meadow/Meadow.OS/Networking' Module not found: Error: Can't resolve './../../Meadow.Foundation' in '/Users/adam//Documentation/docs/Meadow/Meadow_Basics/IO' Module not found: Error: Can't resolve './../../Meadow.OS' in '/Users/adam//Documentation/docs/Meadow/Meadow_Basics/Meadow.OS' Module not found: Error: Can't resolve './../Meadow.Foundation' in '/Users/adam//Documentation/docs/Meadow/Meadow_Basics' Module not found: Error: Can't resolve './../../Meadow.Foundation/Libraries_and_Frameworks/Maple.Server' in '/Users/adam//Documentation/docs/Meadow/Meadow․Foundation/Libraries_and_Frameworks' Module not found: Error: Can't resolve './../../Meadow.Foundation/Libraries_and_Frameworks/Maple.Server' in '/Users/adam//Documentation/docs/Meadow/Release_Notes/Beta4' Module not found: Error: Can't resolve './Meadow.Foundation' in '/Users/adam//Documentation/docs/Meadow' client (webpack 5.89.0) compiled with 10 errors

Your environment

  • Public source code:
  • Public site URL:
  • Docusaurus version used: 2, (pretty involved to upgrade to 3, but we plan on it)
  • Environment name and version (e.g. Chrome 89, Node.js 16.4): Node 18.15.0
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS): Mac OS Ventura 13.2.1, Ubuntu on the build server

Self-service

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

adunndevster2 avatar Dec 08 '23 16:12 adunndevster2

It appears that this only affects links when the final URL segment contains a period. So, while /something/something.something would faile, /something/something.something/another would work fine. It also still fails for all the variants on that URL that resolve to the same page.

  • /something/something.something -> fail
  • /something/something.something/ -> fail
  • /something/something.something/index -> fail
  • /something/something.something/index.md -> fail

I've also tried a backslash without any luck.

  • /something/something\.something/ -> fail

Workaround

It's not a great solution, but it appears you can work around this issue by encoding the final segment's URL using percent encoding, which isn't strictly necessary for URL encoding. By swapping the . to %2E, it seems that the routing system is appeased.

  • /something/something%2Esomething/ (or /Meadow%2EFoundation for the original example).

patridge avatar Jan 25 '24 01:01 patridge