Skip to content

Commit 20264e5

Browse files
committed
Add .pdf extension if it's not already included in the file name
1 parent ef67ada commit 20264e5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

components/quickbooks/actions/download-pdf/download-pdf.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = {
55
name: 'Download PDF',
66
description: 'Download an invoice, bill, purchase order, etc. as a PDF and save it in the temporary file system for use in a later step.',
77
key: 'download_pdf',
8-
version: '0.1.1',
8+
version: '0.1.3',
99
type: 'action',
1010
props: {
1111
quickbooks,
@@ -43,14 +43,18 @@ module.exports = {
4343
responseType: 'arraybuffer',
4444
})
4545

46-
const file_path = '/tmp/' + (file_name || id)
46+
const file_path = '/tmp/' + file_name
4747
fs.writeFileSync(file_path, file)
4848

4949
return file_path
5050
}
5151
},
5252
async run({ $ }){
53-
const file_path = await this.downloadPDF(this.entity, this.id, this.file_name)
53+
const file_name = this.file_name || this.id
54+
const file_name_with_extension = file_name.endsWith('.pdf') ? file_name : file_name + '.pdf'
55+
56+
const file_path = await this.downloadPDF(this.entity, this.id, file_name_with_extension)
5457
$.export('file_path', file_path)
58+
$.export('file_name', file_name_with_extension)
5559
}
5660
}

0 commit comments

Comments
 (0)