fix: preserve newlines in reply tags
This commit is contained in:
@@ -109,6 +109,15 @@ describe("directive parsing", () => {
|
||||
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",
|
||||
"msg-2",
|
||||
);
|
||||
expect(res.replyToId).toBe("msg-2");
|
||||
expect(res.cleaned).toBe("line 1\nline 2\n\nline 3");
|
||||
});
|
||||
|
||||
it("strips reply tags and maps reply_to_current to MessageSid", async () => {
|
||||
await withTempHome(async (home) => {
|
||||
vi.mocked(runEmbeddedPiAgent).mockResolvedValue({
|
||||
|
||||
@@ -193,7 +193,10 @@ export function extractReplyToTag(
|
||||
hasTag = true;
|
||||
}
|
||||
|
||||
cleaned = cleaned.replace(/\s+/g, " ").trim();
|
||||
cleaned = cleaned
|
||||
.replace(/[ \t]+/g, " ")
|
||||
.replace(/[ \t]*\n[ \t]*/g, "\n")
|
||||
.trim();
|
||||
return { cleaned, replyToId, hasTag };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user