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 = {
|
const disposition = {
|
||||||
csv(result, options = {}) {
|
csv(result, options = {}) {
|
||||||
|
let value = options.value;
|
||||||
|
|
||||||
|
if (typeof options.value === 'function') {
|
||||||
|
value = options.value();
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'Content-Disposition': options.value,
|
'Content-Disposition': value,
|
||||||
'Content-Type': 'text/csv'
|
'Content-Type': 'text/csv'
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
|
@ -140,7 +140,11 @@ const subscribers = {
|
||||||
exportCSV: {
|
exportCSV: {
|
||||||
headers: {
|
headers: {
|
||||||
disposition: {
|
disposition: {
|
||||||
type: 'csv'
|
type: 'csv',
|
||||||
|
value() {
|
||||||
|
const datetime = (new Date()).toJSON().substring(0, 10);
|
||||||
|
return `Attachment; filename="subscribers.${datetime}.csv"`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
response: {
|
response: {
|
||||||
|
|
|
@ -199,7 +199,7 @@ describe('Subscribers API', function () {
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
should.not.exist(res.headers['x-cache-invalidate']);
|
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(/id,email,created_at,deleted_at/);
|
||||||
res.text.should.match(/subscriber1@test.com/);
|
res.text.should.match(/subscriber1@test.com/);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue