fix: leave subject blank (not "Fwd:") for a subject-less message
buildForwardAsAttachmentPayload called buildForwardSubject(email.subject,
forwardPrefix) unconditionally, and buildForwardSubject("", prefix)
returns just the bare prefix rather than "". Normal Forward doesn't do
this - EmailComposer's getInitialSubject() returns "" outright when
!replyTo?.subject, only calling buildForwardSubject when there's an
actual subject to prefix. So forwarding a subject-less message as an
attachment produced "Fwd:" as the subject, while normal Forward left
it blank.
Only call buildForwardSubject when email.subject is truthy, matching
getInitialSubject()'s behavior exactly. Add a test.
Caught by GitHub Copilot's automated PR review.
This commit is contained in:
@@ -46,6 +46,12 @@ describe('buildForwardAsAttachmentPayload', () => {
|
|||||||
expect(payload?.subject).toBe('Fwd: already forwarded once');
|
expect(payload?.subject).toBe('Fwd: already forwarded once');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('leaves the subject blank (not just the bare prefix) for a subject-less message, matching normal Forward', () => {
|
||||||
|
const email = makeEmail({ subject: undefined });
|
||||||
|
const payload = buildForwardAsAttachmentPayload(email, 'Fwd:');
|
||||||
|
expect(payload?.subject).toBe('');
|
||||||
|
});
|
||||||
|
|
||||||
it('honors a custom filename template, matching "Export as .eml" naming instead of always using the default', () => {
|
it('honors a custom filename template, matching "Export as .eml" naming instead of always using the default', () => {
|
||||||
const email = makeEmail({ subject: 'Missed spam example' });
|
const email = makeEmail({ subject: 'Missed spam example' });
|
||||||
const payload = buildForwardAsAttachmentPayload(email, 'Fwd:', {
|
const payload = buildForwardAsAttachmentPayload(email, 'Fwd:', {
|
||||||
|
|||||||
@@ -41,7 +41,11 @@ export function buildForwardAsAttachmentPayload(
|
|||||||
if (!email.blobId) return null;
|
if (!email.blobId) return null;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
subject: buildForwardSubject(email.subject, forwardPrefix),
|
// Match the normal Forward flow's getInitialSubject(), which leaves the
|
||||||
|
// subject blank rather than prefix-only when the original has none -
|
||||||
|
// buildForwardSubject("", prefix) would otherwise return just the bare
|
||||||
|
// prefix (e.g. "Fwd:") for a subject-less message.
|
||||||
|
subject: email.subject ? buildForwardSubject(email.subject, forwardPrefix) : "",
|
||||||
attachment: {
|
attachment: {
|
||||||
blobId: email.blobId,
|
blobId: email.blobId,
|
||||||
name: emailExportFilename(email, filenameOptions),
|
name: emailExportFilename(email, filenameOptions),
|
||||||
|
|||||||
Reference in New Issue
Block a user