fix(api): escape Markdown and adjust compare link formatting
Ensure parentheses are escaped in section headers, switch to en dash in heading, and avoid Markdown links by outputting escaped text and URL. Also improve line breaks for consistent layout.
This commit is contained in:
19
x.js
19
x.js
@@ -246,7 +246,7 @@ function formatCommitMessage(payload) {
|
||||
let filesList = '';
|
||||
|
||||
if (allAdded.size > 0) {
|
||||
filesList += `\n➕ *Added (${allAdded.size}):*\n`;
|
||||
filesList += `\n➕ *Added \\(${allAdded.size}\\):*\n`;
|
||||
Array.from(allAdded).slice(0, 10).forEach(file => {
|
||||
filesList += ` • \`${escapeInlineCode(file)}\`\n`;
|
||||
});
|
||||
@@ -256,7 +256,7 @@ function formatCommitMessage(payload) {
|
||||
}
|
||||
|
||||
if (allModified.size > 0) {
|
||||
filesList += `\n📝 *Modified (${allModified.size}):*\n`;
|
||||
filesList += `\n📝 *Modified \\(${allModified.size}\\):*\n`;
|
||||
Array.from(allModified).slice(0, 10).forEach(file => {
|
||||
filesList += ` • \`${escapeInlineCode(file)}\`\n`;
|
||||
});
|
||||
@@ -266,7 +266,7 @@ function formatCommitMessage(payload) {
|
||||
}
|
||||
|
||||
if (allRemoved.size > 0) {
|
||||
filesList += `\n❌ *Removed (${allRemoved.size}):*\n`;
|
||||
filesList += `\n❌ *Removed \\(${allRemoved.size}\\):*\n`;
|
||||
Array.from(allRemoved).slice(0, 10).forEach(file => {
|
||||
filesList += ` • \`${escapeInlineCode(file)}\`\n`;
|
||||
});
|
||||
@@ -284,13 +284,15 @@ function formatCommitMessage(payload) {
|
||||
|
||||
// Escape heading line content and link text/url appropriately
|
||||
const repoEsc = escapeMdV2(repo);
|
||||
const heading = `🚀 *${repoEsc}* - ${totalCommits} ${commitWord} pushed`;
|
||||
// Use en dash and keep the rest escaped via escapeMdV2 for safety
|
||||
const heading = `🚀 *${repoEsc}* – ${totalCommits} ${commitWord} pushed`;
|
||||
|
||||
let compare = '';
|
||||
if (payload.compare_url) {
|
||||
// Safer to avoid Markdown link syntax; print escaped text and URL
|
||||
const linkText = escapeMdV2('Compare Changes');
|
||||
const linkUrl = escapeMdV2(payload.compare_url);
|
||||
compare = `[${linkText}](${linkUrl})`;
|
||||
compare = `${linkText}: ${linkUrl}`;
|
||||
}
|
||||
|
||||
// Try to append a German executive summary of the most recent commit.
|
||||
@@ -308,10 +310,11 @@ function formatCommitMessage(payload) {
|
||||
// already logged inside summarizer; keep silent here
|
||||
}
|
||||
|
||||
// Ensure each section starts on its own line; compare may be plain URL text.
|
||||
return `${heading}
|
||||
${commitsText}
|
||||
${filesList}
|
||||
${compare}${summaryBlock}`;
|
||||
${commitsText}
|
||||
${filesList}
|
||||
${compare ? `\n${compare}` : ''}${summaryBlock}`;
|
||||
})();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user