mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +00:00
chore: auto-fix lint & formatting [skip ci]
This commit is contained in:
parent
50ae8c7607
commit
7179a35457
2 changed files with 12 additions and 4 deletions
|
|
@ -43,11 +43,14 @@ describe("telegram renderNeutralMessage", () => {
|
|||
it("converts Discord markdown to Telegram HTML", () => {
|
||||
const out = renderNeutralMessage({
|
||||
title: "acme/widget#7: Add feature",
|
||||
description: "**1** commit pushed to `main`\n[View comparison](https://github.com/acme/widget/compare/a...b)",
|
||||
description:
|
||||
"**1** commit pushed to `main`\n[View comparison](https://github.com/acme/widget/compare/a...b)",
|
||||
fields: [{ name: "Status", value: "**ok** and `done`" }],
|
||||
});
|
||||
expect(out).toContain("<b>1</b> commit pushed to <code>main</code>");
|
||||
expect(out).toContain('<a href="https://github.com/acme/widget/compare/a...b">View comparison</a>');
|
||||
expect(out).toContain(
|
||||
'<a href="https://github.com/acme/widget/compare/a...b">View comparison</a>',
|
||||
);
|
||||
expect(out).toContain("<b>Status</b>: <b>ok</b> and <code>done</code>");
|
||||
});
|
||||
|
||||
|
|
@ -166,7 +169,9 @@ describe("TelegramDriver", () => {
|
|||
let capturedUrl = "";
|
||||
mockFetch((url) => {
|
||||
capturedUrl = url;
|
||||
return new Response(JSON.stringify({ ok: true, result: { message_id: 10 } }), { status: 200 });
|
||||
return new Response(JSON.stringify({ ok: true, result: { message_id: 10 } }), {
|
||||
status: 200,
|
||||
});
|
||||
});
|
||||
|
||||
const driver = new TelegramDriver();
|
||||
|
|
|
|||
|
|
@ -10,7 +10,10 @@ function esc(s: string): string {
|
|||
|
||||
function mdToHtml(s: string): string {
|
||||
let out = esc(s);
|
||||
out = out.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_m, label, url) => `<a href="${esc(url)}">${label}</a>`);
|
||||
out = out.replace(
|
||||
/\[([^\]]+)\]\(([^)]+)\)/g,
|
||||
(_m, label, url) => `<a href="${esc(url)}">${label}</a>`,
|
||||
);
|
||||
out = out.replace(/\*\*([^*]+)\*\*/g, "<b>$1</b>");
|
||||
out = out.replace(/`([^`]+)`/g, "<code>$1</code>");
|
||||
out = out.replace(/(^|[^*])\*([^*]+)\*/g, "$1<i>$2</i>");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue