diegomura / diegomura/react-pdf
Wrong extension when downloading a pdf with PDFDownloadLink when filename ending with .fr (for instance)
- Dominant language
- TypeScript
- Stars
- 16.8k
- Forks
- 1.3k
- Avg merge
- 5h 6m
- Merged PRs (30d)
- 52
Description
**Describe the bug**
Hi !
I encountered a bug (or at least an unexpected behaviour) when using the [PDFDownloadLink](https://github.com/diegomura/react-pdf/blob/ca360e0f7e0f2640c002968135bd939dafd86a03/packages/renderer/src/dom/PDFDownloadLink.js) component.
We pass two arguments:
- a JSX pdf document (with e.g. Document, Image, Page, Text, View components)
- a generated filename
If the filename is ending with `.COM` for instance (or `.txt`, ...), the generated file does not contain the `.pdf` extension. Is this something expected ?
One way to fix this could be to check in the PDFDownloadLink if the filename is ending with pdf and adding it is not, but the current behaviour could be the expected one, I don't know.
**To Reproduce**
Steps to reproduce the behavior including code snippet (if applies):
Clicking on the link generated here will produce a file ending with a .txt extension instead of a .pdf.
```tsx
Toto
}
fileName="test.pdf"
>
Download
```
_You can make use of [react-pdf REPL](https://react-pdf.org/repl) to share the snippet_
**Expected behavior**
The filename should always end with a `.pdf` extension
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [MacOS]
- Browser [Chrome]
- React-pdf version [2.0.20]
Contributor guide
Assessment
This issue has not been assessed yet.