facebook / facebook/docusaurus

asset links with trailing slash true can be broken

Aperta
#6,282 6 commenti 1 reazione 0 assegnatari Vedi su GitHub
bug domain: trailing slash
Lingua principale
TypeScript
Stelle
66.2k
Fork
10k
Merge medio
1g 3h
PR unite (30g)
52

Descrizione

### Have you read the Contributing Guidelines on issues?

- [X] I have read the [Contributing Guidelines on issues](https://github.com/facebook/docusaurus/blob/main/CONTRIBUTING.md#reporting-new-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 have a hosting provider where trailing slash true is required, and that works great. However, for direct links to files, it is broken.

I have a file in the docs folder (which is also versioned), and a link in .md doc like so
```
[Download this docx using Markdown](./assets/docusaurus-asset-example.docx)
```

However that link is transformed to `.../assets/file/haash.docx/` and that link ends up as a 404, as it's treated as path by host, rather than resolving the file.

I think asset links should never get a trailing slash, but I don't have enough knowledge of other platforms to say that definitively.

### Steps to reproduce

You can use the docusaurus docs to reproduce

1. set trailing slash true
2. npm run build
3. npm run serve as an example server that is broken (I self host with Apache, and have the same problem)

On the /docs/markdown-features/assets#files page, attempt to open the .docx file links.

### Expected behavior

It opens the linked file. File assets should probably never have trailing slashes, some hosts seem to be fine with it, but not all. I imagine all however a fine without for file assets.

### Actual behavior

Document not found.

### Your environment

- Public source code:
- Public site URL:
- Docusaurus version used: beta.14
- Environment name and version (e.g. Chrome 89, Node.js 16.4): hosted with apache
- Operating system and version (e.g. Ubuntu 20.04.2 LTS):

### Reproducible demo

_No response_

### Self-service

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

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.