diff --git a/src/components/FileName.tsx b/src/components/FileName.tsx index d64353bd..4df4c46d 100644 --- a/src/components/FileName.tsx +++ b/src/components/FileName.tsx @@ -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 ( diff --git a/src/plugins/pdf/components/PDFControls.tsx b/src/plugins/pdf/components/PDFControls.tsx index a9a5e0af..ddd7f567 100644 --- a/src/plugins/pdf/components/PDFControls.tsx +++ b/src/plugins/pdf/components/PDFControls.tsx @@ -30,7 +30,7 @@ const PDFControls: FC<{}> = () => { diff --git a/src/types/index.ts b/src/types/index.ts index eb50b4a4..adc561b9 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -37,6 +37,7 @@ export interface IDocument { uri: string; fileType?: string; fileData?: string | ArrayBuffer; + fileName?: string; } export interface DocRendererProps {