mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
🐛 Fixed missing filename when exporting subscribers csv
closes #10075 - the filename was missing
This commit is contained in:
parent
5f7401051c
commit
8d12c8908f
3 changed files with 13 additions and 3 deletions
|
@ -11,8 +11,14 @@ const cacheInvalidate = (result, options = {}) => {
|
|||
|
||||
const disposition = {
|
||||
csv(result, options = {}) {
|
||||
let value = options.value;
|
||||
|
||||
if (typeof options.value === 'function') {
|
||||
value = options.value();
|
||||
}
|
||||
|
||||
return {
|
||||
'Content-Disposition': options.value,
|
||||
'Content-Disposition': value,
|
||||
'Content-Type': 'text/csv'
|
||||
};
|
||||
},
|
||||
|
|
|
@ -140,7 +140,11 @@ const subscribers = {
|
|||
exportCSV: {
|
||||
headers: {
|
||||
disposition: {
|
||||
type: 'csv'
|
||||
type: 'csv',
|
||||
value() {
|
||||
const datetime = (new Date()).toJSON().substring(0, 10);
|
||||
return `Attachment; filename="subscribers.${datetime}.csv"`;
|
||||
}
|
||||
}
|
||||
},
|
||||
response: {
|
||||
|
|
|
@ -199,7 +199,7 @@ describe('Subscribers API', function () {
|
|||
.expect(200)
|
||||
.then((res) => {
|
||||
should.not.exist(res.headers['x-cache-invalidate']);
|
||||
|
||||
res.headers['content-disposition'].should.match(/Attachment;\sfilename="subscribers/);
|
||||
res.text.should.match(/id,email,created_at,deleted_at/);
|
||||
res.text.should.match(/subscriber1@test.com/);
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue