Skip to content

The Open Source DocuSign Alternative.

fix: simplify code

Lucas Smith0d15b80c2d6f
diff --git a/packages/lib/client-only/download-pdf.ts b/packages/lib/client-only/download-pdf.ts
index e095002ee..ec7d0c252 100644
--- a/packages/lib/client-only/download-pdf.ts
+++ b/packages/lib/client-only/download-pdf.ts
@@ -15,10 +15,13 @@ export const downloadPDF = async ({ documentData, fileName }: DownloadPDFProps)
});
const link = window.document.createElement('a');
- const baseTitle = fileName?.includes('.pdf') ? fileName.split('.pdf')[0] : fileName;
+
+ const [baseTitle] = fileName?.includes('.pdf')
+ ? fileName.split('.pdf')
+ : [fileName ?? 'document'];
link.href = window.URL.createObjectURL(blob);
- link.download = baseTitle ? `${baseTitle}_signed.pdf` : 'document.pdf';
+ link.download = `${baseTitle}_signed.pdf`;
link.click();