tags into the URL, which broke the link in Telegram.
input: "[3 → 10 сентября — от $202](https://www.google.com/travel/flights/search?tfs=CBwQAho_EgoyURL_safe_base64)",
expected: `3 → 10 сентября — от $202`,
},
{
name: "multiple links all survive",
input: "[first](https://a.com/path_one) and [second](https://b.com/path_two_x)",
expected: `first and second`,
},
{
name: "markdown link query params are escaped in href",
input: "[oauth](https://example.com/cb?response_type=code&client_id=test-client)",
expected: `oauth`,
},
{
name: "link label with HTML special chars is escaped",
input: "[a & b](https://example.com)",
expected: `a & b`,
},
{
name: "HTML special chars in plain text are escaped",
input: "a & b < c > d",
expected: "a & b < c > d",
},
{
name: "code block with language",
input: "```json\n{\n \"path\": \"README.md\"\n}\n```",
expected: "{\n \"path\": \"README.md\"\n}\n
",
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
actual := markdownToTelegramHTML(tc.input)
require.Equal(t, tc.expected, actual)
})
}
}