Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ const myHeader: IHeaderOverride = (state, previousDocument, nextDocument) => {
| --------- | -------- |
| uri | `string` |
| fileType? | `string` |
| fileName? | `string` |
| fileData? | `string | ArrayBuffer` - **Used Internally - Ignored if passed into props** |

---
Expand Down
22 changes: 14 additions & 8 deletions src/components/FileName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@ export const FileName: FC<{}> = () => {

if (!currentDocument || config?.header?.disableFileName) return null;

let fileName = currentDocument.uri || "";
fileName = decodeURI(fileName);
let fileName = "";

if (!config?.header?.retainURLParams) {
fileName = fileName.split("?")[0];
}
if (currentDocument.fileName) {
fileName = currentDocument.fileName;
} else {
fileName = currentDocument.uri || "";
fileName = decodeURI(fileName);

if (!config?.header?.retainURLParams) {
fileName = fileName.split("?")[0];
}

const splitURL = fileName.split("/");
if (splitURL.length) {
fileName = splitURL[splitURL.length - 1];
const splitURL = fileName.split("/");
if (splitURL.length) {
fileName = splitURL[splitURL.length - 1];
}
}

return (
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/pdf/components/PDFControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const PDFControls: FC<{}> = () => {
<DownloadButton
id="pdf-download"
href={currentDocument?.fileData as string}
download={currentDocument?.uri}
download={currentDocument?.fileName || currentDocument?.uri}
>
<DownloadPDFIcon color="#000" size="75%" />
</DownloadButton>
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface IDocument {
uri: string;
fileType?: string;
fileData?: string | ArrayBuffer;
fileName?: string;
}

export interface DocRendererProps {
Expand Down