fix(telegram): render HTML with markdown-it and strip HTML from Discord bodies

This commit is contained in:
RhenCloud 2026-08-18 18:29:17 +08:00
parent ea049e28c9
commit 9899cd01bf
No known key found for this signature in database
GPG key ID: A574A617378C4E0B
7 changed files with 90 additions and 18 deletions

View file

@ -523,6 +523,46 @@ describe("limits and localization", () => {
expect(msg.fields!.every((f) => f.value.length <= 1024)).toBe(true);
expect(msg.description!.length).toBe(4096);
});
it("strips HTML tags from issue and PR bodies", () => {
const issue = formatEvent(
route,
event("issues", {
action: "opened",
issue: {
number: 3,
title: "Bug",
html_url: "https://github.com/acme/widget/issues/3",
body: "Use <b>bold</b> and <code>code</code>",
},
repository: repo,
sender,
}),
);
expect(issue.description).toContain("Use bold and code");
expect(issue.description).not.toContain("<b>");
expect(issue.description).not.toContain("<code>");
const pr = formatEvent(
route,
event("pull_request", {
action: "opened",
pull_request: {
number: 7,
title: "Add feature",
state: "open",
html_url: "https://github.com/acme/widget/pull/7",
body: 'Fixes <a href="https://x.example">the bug</a>',
head: { ref: "feat" },
base: { ref: "main" },
},
repository: repo,
sender,
}),
);
expect(pr.description).toContain("Fixes the bug");
expect(pr.description).not.toContain("<a ");
});
});
describe("forge source branding", () => {