Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function truncateCommitMessage(message: string, repo: any): string {
const title = message.split("\n")[0];
const escapedTitle = slack.escape(title);
const linkedTitle = linkIssues(escapedTitle, repo);
if (linkedTitle.length <= 50) {
return linkedTitle;
}
const splitRegExp = /(&(?:[gl]t|amp);|<.*?\||>)/;
const titleParts = linkedTitle.split(splitRegExp);
let truncatedTitle = "";
let addNext = 1;
let i;
for (i = 0; i < titleParts.length; i++) {
let newTitle = truncatedTitle;
if (i % 2 === 0) {
newTitle += titleParts[i];
} else if (/^&(?:[gl]t|amp);$/.test(titleParts[i])) {