Skip to content

Commit d85ce28

Browse files
webstechdscho
authored andcommitted
Support mostly lowercase In-reply-to header
Some email handlers may only capitalize the first char. Signed-off-by: Chris. Webster <chris@webstech.net>
1 parent c7071c1 commit d85ce28

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/send-mail.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export function parseMBoxMessageIDAndReferences(parsed: IParsedMBox):
114114
const msgIdRegex =
115115
/^\s*<([^>]+)>(\s*|,)(\([^")]*("[^"]*")?\)\s*|\([^)]*\)$)?(<.*)?$/;
116116
for (const header of parsed.headers ?? []) {
117-
if (header.key === "In-Reply-To" || header.key === "References") {
117+
if (header.key.match(/In-Reply-To|References/i)) {
118118
let value: string = header.value.replace(/[\r\n]/g, " ");
119119
while (value) {
120120
const match = value.match(msgIdRegex);

tests/send-mail.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,16 @@ References: <pull.986.git.1624559401.gitgitgadget@gmail.com>
183183
Date: Thu, 24 Feb 2022 12:35:13 -0800
184184
In-Reply-To: <CAPMMpogerttWdjGBNxJaqHT4bd3_igDx4_Fxev2eNHqexZ=aLQ@mail.gmail.com>
185185
(Tao Klerks's message of "Thu, 24 Feb 2022 18:52:27 +0100")
186+
In-reply-to: <lowerReply@mail.gmail.com>
187+
(Tao Klerks's message of "Thu, 24 Feb 2022 18:52:27 +0100")
186188
Message-ID: <xmqq5yp4knpa.fsf@gitster.g>
187189
188190
I can be pursuaded either way.
189191
`;
190192
const parsed = await parseMBox(mbox);
191193
const { messageID, references } = parseMBoxMessageIDAndReferences(parsed);
192194
expect(messageID).toEqual("xmqq5yp4knpa.fsf@gitster.g");
193-
expect(references).toHaveLength(4);
195+
expect(references).toHaveLength(5);
194196
expect(references[0]).toEqual("pull.986.git.1624559401.gitgitgadget@gmail.com");
195-
});
197+
expect(references[4]).toEqual("lowerReply@mail.gmail.com");
198+
});

0 commit comments

Comments
 (0)