@@ -37,7 +37,11 @@ function matchEmoji (emoji) {
3737 return ( spec ) => spec . emoji === emoji || spec . emoji === emoji + IMAGE_STYLE_SELECTOR
3838}
3939
40- function parseGitmoji ( { subject = '' , message = '' , body = '' } = { } , issues = [ ] ) {
40+ function parseGitmoji ( {
41+ subject = '' ,
42+ message = '' ,
43+ body = ''
44+ } = { } , issues = [ ] ) {
4145 subject = emojify ( subject . trim ( ) )
4246 if ( issues . length > 0 ) {
4347 subject = issues . reduce ( ( acc , curr ) => acc . replace ( curr . text , '' ) , subject ) . trim ( )
@@ -48,9 +52,24 @@ function parseGitmoji ({ subject = '', message = '', body = '' } = {}, issues =
4852
4953 const gitmoji = matched [ 0 ]
5054 const semver = gitmojis . find ( matchEmoji ( gitmoji ) ) ?. semver || 'other'
51- subject = subject . replace ( new RegExp ( '^' + gitmoji ) , '' )
52-
53- return { subject, message : subject + '\n\n' + body , gitmoji, semver }
55+ try {
56+ subject = subject . replace ( new RegExp ( '^' + gitmoji ) , '' )
57+ } catch ( SyntaxError ) {
58+ /**
59+ * The emojiRegex is not bugproof, it may return a regex character
60+ * (like * or .). The best option is to ignore this error
61+ * If there is an error, there is no emoji
62+ *
63+ * @see https://github.com/momocow/semantic-release-gitmoji/issues/76
64+ */
65+ return null
66+ }
67+ return {
68+ subject,
69+ message : subject + '\n\n' + body ,
70+ gitmoji,
71+ semver
72+ }
5473}
5574
5675module . exports = function parseCommits ( commits = [ ] , mixins = { } , options = { } ) {
0 commit comments