diff --git a/lib/__tests__/forward-as-attachment.test.ts b/lib/__tests__/forward-as-attachment.test.ts index c52aeb13..4dc92cf4 100644 --- a/lib/__tests__/forward-as-attachment.test.ts +++ b/lib/__tests__/forward-as-attachment.test.ts @@ -46,6 +46,12 @@ describe('buildForwardAsAttachmentPayload', () => { 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', () => { const email = makeEmail({ subject: 'Missed spam example' }); const payload = buildForwardAsAttachmentPayload(email, 'Fwd:', { diff --git a/lib/forward-as-attachment.ts b/lib/forward-as-attachment.ts index 3058c2ec..42c4bde8 100644 --- a/lib/forward-as-attachment.ts +++ b/lib/forward-as-attachment.ts @@ -41,7 +41,11 @@ export function buildForwardAsAttachmentPayload( if (!email.blobId) return null; 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: { blobId: email.blobId, name: emailExportFilename(email, filenameOptions),