Skip to content

Commit

Permalink
feat: escape markdown characters in user provided strings (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Jan 16, 2022
1 parent eadf9e3 commit 76bab97
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions commit-to-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ function toStringMarkdown (data) {
s += `* \\[[\`${data.sha.substr(0, 10)}\`](${data.shaUrl})] - `
s += (data.semver || []).length ? `**(${data.semver.join(', ').toUpperCase()})** ` : ''
s += data.revert ? '***Revert*** "' : ''
s += data.group ? `**${data.group}**: ` : ''
s += data.group ? `**${cleanMarkdown(data.group)}**: ` : ''
s += cleanMarkdown(data.summary)
s += data.revert ? '" ' : ' '
s += data.author ? `(${data.author}) ` : ''
s += data.author ? `(${cleanMarkdown(data.author)}) ` : ''
s += data.pr ? `[${data.pr}](${data.prUrl})` : ''
s = s.trim()

Expand Down
8 changes: 8 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,11 @@ test('test backtick strings in commit messages', (t) => {
`)
t.end()
})

test('test markdown punctuation chars in commit message and author name', (t) => {
t.equal(
exec('--start-ref=eadf9e3d32 --end-ref=eadf9e3d32 --filter-release --commit-url=https://yeehaw.com/{ref}/{ref}/{ghUser}/{ghRepo}/'),
`* \\[[\`eadf9e3d32\`](https://yeehaw.com/eadf9e3d32/eadf9e3d32/nodejs/changelog-maker/)] - **group\\_with\\_underscore**: test commit message (Author\\_name\\_with\\_underscore)
`)
t.end()
})

0 comments on commit 76bab97

Please sign in to comment.