0
Fork 0
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:
kirrg001 2018-10-27 18:39:39 +02:00
parent 5f7401051c
commit 8d12c8908f
3 changed files with 13 additions and 3 deletions

View file

@ -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'
};
},

View file

@ -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: {

View file

@ -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/);
});