Skip to content

Commit

Permalink
chore: Fix discord message newline issue
Browse files Browse the repository at this point in the history
  • Loading branch information
kitten committed Apr 22, 2024
1 parent b67d40e commit d248b5b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions .github/actions/discord-message/action.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@ const formatBody = (input) => {
const updatedDepsRe = /\n-\s*Updated dependencies[\s\S]+\n(\n\s+-[\s\S]+)*/gi;
const markdownLinkRe = /\[([^\]]+)\]\(([^\)]+)\)/g;
const creditRe = new RegExp(`Submitted by (?:undefined|${markdownLinkRe.source})`, 'ig');
const repeatedNewlineRe = /(\n[ ]*)+/g;
const repeatedNewlineRe = /(?:\n[ ]*)*(\n[ ]*)/g;
return input
.replace(titleRe, '')
.replace(updatedDepsRe, '')
.replace(creditRe, (_match, text, url) => {
if (!text || /@kitten|@JoviDeCroock/i.test(text)) return '';
return `Submitted by [${text}](${url})`;
})
.replace(markdownLinkRe, (_match, text, url) => {
return `[${text}](<${url}>)`;
})
.replace(repeatedNewlineRe, '\n')
.replace(markdownLinkRe, (_match, text, url) => `[${text}](<${url}>)`)
.replace(repeatedNewlineRe, (_match, text) => text || '\n')
.trim();
};

Expand Down

0 comments on commit d248b5b

Please sign in to comment.