diegomura / diegomura/react-pdf

Wrong extension when downloading a pdf with PDFDownloadLink when filename ending with .fr (for instance)

Open
#1,901 0 comments 0 reactions 0 assignees View on GitHub
bug
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.