-
-
Notifications
You must be signed in to change notification settings - Fork 11.7k
fix: include site name in members CSV export filename (#28310) #28362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ const membersService = require('../../services/members'); | |
| const settingsCache = require('../../../shared/settings-cache'); | ||
| const tpl = require('@tryghost/tpl'); | ||
| const _ = require('lodash'); | ||
| const {slugify} = require('@tryghost/string'); | ||
|
|
||
| const messages = { | ||
| memberNotFound: 'Member not found.', | ||
|
|
@@ -378,7 +379,9 @@ const controller = { | |
| type: 'csv', | ||
| value() { | ||
| const datetime = (new Date()).toJSON().substring(0, 10); | ||
| return `members.${datetime}.csv`; | ||
| const title = settingsCache.get('title'); | ||
| const titlePrefix = title ? `${slugify(title)}.` : ''; | ||
| return `${titlePrefix}ghost.members.${datetime}.csv`; | ||
| } | ||
|
Comment on lines
+382
to
385
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Filename prefix logic may never reach clients because CSV serializer hardcodes At Line 384 you return a prefixed filename, but Suggested fix (propagate endpoint filename into stream serializer)# ghost/core/core/server/api/endpoints/utils/serializers/output/members.js
- res.setHeader('Content-Disposition', `attachment; filename="members.${datetime}.csv"`);
+ const fallbackFilename = `members.${datetime}.csv`;
+ const disposition = res.getHeader('Content-Disposition');
+ if (!disposition) {
+ res.setHeader('Content-Disposition', `attachment; filename="${fallbackFilename}"`);
+ }# ghost/core/core/server/api/endpoints/members.js
value() {
const datetime = (new Date()).toJSON().substring(0, 10);
const title = settingsCache.get('title');
const titlePrefix = title ? `${slugify(title)}.` : '';
return `${titlePrefix}ghost.members.${datetime}.csv`;
}🤖 Prompt for AI Agents |
||
| }, | ||
| contentType: 'text/csv', | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard against empty slug output to preserve the documented fallback filename.
At Line 383, fallback is based on raw
titletruthiness. Iftitleexists but slugifies to an empty string, Line 384 can emit.ghost.members.{date}.csvinstead ofghost.members.{date}.csv.Suggested fix (fallback on slug result, not raw title)
🤖 Prompt for AI Agents