fix: allow whitespace in reply tags (#560) (thanks @mcinteerj)

This commit is contained in:
Peter Steinberger
2026-01-09 17:03:44 +01:00
parent 4381b03412
commit 7d9300e0f5
3 changed files with 14 additions and 1 deletions

View File

@@ -162,12 +162,24 @@ describe("directive parsing", () => {
expect(res.cleaned).toBe("ok");
});
it("extracts reply_to_current tag with whitespace", () => {
const res = extractReplyToTag("ok [[ reply_to_current ]]", "msg-1");
expect(res.replyToId).toBe("msg-1");
expect(res.cleaned).toBe("ok");
});
it("extracts reply_to id tag", () => {
const res = extractReplyToTag("see [[reply_to:12345]] now", "msg-1");
expect(res.replyToId).toBe("12345");
expect(res.cleaned).toBe("see now");
});
it("extracts reply_to id tag with whitespace", () => {
const res = extractReplyToTag("see [[ reply_to : 12345 ]] now", "msg-1");
expect(res.replyToId).toBe("12345");
expect(res.cleaned).toBe("see now");
});
it("preserves newlines when stripping reply tags", () => {
const res = extractReplyToTag(
"line 1\nline 2 [[reply_to_current]]\n\nline 3",

View File

@@ -22,7 +22,7 @@ export function extractReplyToTag(
const idMatch = cleaned.match(/\[\[\s*reply_to\s*:\s*([^\]\n]+)\s*\]\]/i);
if (idMatch?.[1]) {
cleaned = cleaned.replace(/\[\[\s*reply_to\s*:[^\]\n]+\]\]/gi, " ");
cleaned = cleaned.replace(/\[\[\s*reply_to\s*:\s*[^\]\n]+\s*\]\]/gi, " ");
replyToId = idMatch[1].trim();
hasTag = true;
}