Merge pull request #560 from mcinteerj/fix/reply-tags-whitespace
Auto-Reply: relax regex for reply tags to allow whitespace
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -11,18 +11,18 @@ export function extractReplyToTag(
|
||||
let replyToId: string | undefined;
|
||||
let hasTag = false;
|
||||
|
||||
const currentMatch = cleaned.match(/\[\[reply_to_current\]\]/i);
|
||||
const currentMatch = cleaned.match(/\[\[\s*reply_to_current\s*\]\]/i);
|
||||
if (currentMatch) {
|
||||
cleaned = cleaned.replace(/\[\[reply_to_current\]\]/gi, " ");
|
||||
cleaned = cleaned.replace(/\[\[\s*reply_to_current\s*\]\]/gi, " ");
|
||||
hasTag = true;
|
||||
if (currentMessageId?.trim()) {
|
||||
replyToId = currentMessageId.trim();
|
||||
}
|
||||
}
|
||||
|
||||
const idMatch = cleaned.match(/\[\[reply_to:([^\]\n]+)\]\]/i);
|
||||
const idMatch = cleaned.match(/\[\[\s*reply_to\s*:\s*([^\]\n]+)\s*\]\]/i);
|
||||
if (idMatch?.[1]) {
|
||||
cleaned = cleaned.replace(/\[\[reply_to:[^\]\n]+\]\]/gi, " ");
|
||||
cleaned = cleaned.replace(/\[\[\s*reply_to\s*:\s*[^\]\n]+\s*\]\]/gi, " ");
|
||||
replyToId = idMatch[1].trim();
|
||||
hasTag = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user